RaiseError()

Syntax

RaiseError(ErrorNumber)
Description
Artificially create the given error. The appropriate error action will be taken (call of the error handler or program termination by the system if no handler is set). The ErrorNumber will be available inside the error handler with the ErrorCode() command.

Parameters

ErrorNumber On Windows, the error number can include application defined errors. The value can be between 0 and 268435455 (a 27bit number). On Linux or Mac OSX, only the following errors can be raised:
  #PB_OnError_InvalidMemory         : Read or write operation on an invalid location
  #PB_OnError_Floatingpoint         : Floating-point error
  #PB_OnError_Breakpoint            : Debugger breakpoint reached (non-PureBasic breakpoints)
  #PB_OnError_IllegalInstruction    : Attempt to execute an illegal instruction
  #PB_OnError_PriviledgedInstruction: Attempt to execute a privileged (system-) instruction

Return value

None.

Example

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

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

  OnErrorCall(@ErrorHandler())
  RaiseError(#PB_OnError_InvalidMemory)
  
  MessageRequester("OnError test", "This should never be displayed")

See Also

ErrorCode()

Supported OS

All

<- OnErrorGoto() - OnError Index