OnErrorCall()

Syntax

OnErrorCall(@ErrorHandler())
Description
Changes the action taken if an error occurs to call the specified handler procedure. The handler can display information about the error to the user using the commands of this library and do any needed cleanup to shutdown the application. The program will end as soon as the handler returns.

Parameters

@ErrorHandler() The address of a procedure of the following form:
  Procedure ErrorHandler()
    ; Your code here
  EndProcedure

Return value

None.

Example

  Procedure ErrorHandler()
    MessageRequester("OnError test", "The following error happened: " + ErrorMessage())
  EndProcedure

  MessageRequester("OnError test", "Test start")

  OnErrorCall(@ErrorHandler())
  Pokes(10, "Hello World") ; Cause a #PB_OnError_InvalidMemory error
  
  MessageRequester("OnError test", "This should never be displayed")

Supported OS

All

<- NextInstruction() - OnError Index - OnErrorDefault() ->