Changes the action taken when an error occurs back to the system default. This usually means displaying an error dialog and exiting the program, but it may also mean to just ignore certain errors. To exit the program on every error, use OnErrorExit().
When using the OnError library inside a DLL the best practice is to set the error handler at the beginning of every public DLL function and resetting it back to the default with this command before returning to the caller to make sure there is no interference between the OnError library and any exception handling done by the calling program.
Procedure ErrorHandler() MessageRequester("OnError test", "The following error happened: " + ErrorMessage()) EndProcedure MessageRequester("OnError test", "Test start") OnErrorCall(@ErrorHandler()) OnErrorDefault() ; Comment this to get the handler call instead of the system error handling Pokes(10, "Hello World") ; Cause a #PB_OnError_InvalidMemory error MessageRequester("OnError test", "This should never be displayed")