Navigation: Programming Cookbook > Exception Handling >
Win32 Structured Exceptions
The Dolphin VM catches a number of Win32 exceptions (notable examples being GP faults, floating point errors, and integer division by zero) and notifies the image of their occurrence.
The VM catches the Win32 exceptions even if they did not occur in Smalltalk code, but happened in some external library function. For example, if one evaluates:
CRTLibrary default sqrt: -1
Then one gets a walkback resulting from an invalid floating point operation exception that occurs in the C-runtime library's sqrt() function.
The Dolphin exception classes which are created when Win32 structured exceptions occur are:
|•||FloatingPointException. These contain standard IEEE FP error details as an instance of _FPIEEE_RECORD.|
|•||GPFault. These contain the address being accessed when the access violation occurred, and also information such as whether a read or write was being attempted.|
|•||ZeroDivide. Represents integer or floating-point division by zero. Holds the dividend (that which was divided by zero) in the exception tag.|
|•||Win32Fault. Raised when any other Win32 structured exception occurs. Holds the Win32 exception details record (i.e. an instance of EXCEPTION_RECORD) describing the fault. GPFault is actually a specialised Win32Fault.|
Note that although access violations can frequently be recovered from by dismissing the walkback (especially if they arise because of attempts to read inaccessible memory, or to read/write through a null pointer), they may represent just the tip of the iceberg. A GPFault may only be raised after everything has gone horribly wrong, so do not be too surprised if Dolphin subsequently crashes.
If regular GPFaults start to occur during garbage collection activity, then do not save the image, as it has been corrupted, probably by an external function writing off the end of an inadequately sized buffer.
A limitation is that although Win32 structured exceptions can often be resumed, the Dolphin equivalents cannot.