Error System
DarkNet includes a versatile error system which can be used in a variety of ways. There are 3 error modes available; you can use more than one at the same time. mnToggleErrorMode is used to enable or disable an error mode.
All error modes provide useful information about the error. The following information is provided:
-The command that caused the error e.g. mnRecvUDP
-The operation that the command was performing at the time of the error e.g. loading the networking module
-The line within DarkNet's code that the error occurred at e.g. 730
-The file within DarkNet's code that the error occurred in e.g. clInstance.cpp
-The error code of the error e.g. 4300
-The version of DarkNet in use e.g. v1.1.6
EM_MESSAGE_BOX
This error mode is the easiest to use. When an error occurs an error message box appears that looks like this:

EM_SAVE
Under this error mode your application can deal with the error using a set of DarkNet commands. To determine if an error has occurred you can use mnGetErrorFlag. When an error has been detected you can use the mnGetError commands to gather information about the error.
The below screenshot shows an application using EM_SAVE to display its own error report:
EM_EXCEPTION
When using this error mode an exception will be generated when an error occurs. You can catch the exception and use the clError (C++) or mnError (.NET) class to retrieve information about the error. Note: this error mode should not be used in DarkBASIC Pro because it does not support exception handling.
Code
The below code demonstrates how each error mode can be used.
C++
C#
VB.NET
DarkBASIC Pro
|