How error traps work

In PowerBASIC, error codes - returned by the ERR or ERRCLEAR functions - and error traps are local to each Sub or Function.  An error trap will only trap errors that occur within the Sub or Function where it is defined.

PowerBASIC uses the following steps to determine what to do when a run-time error occurs:

Consider the following:

SUB Proc1

  ON ERROR GOTO ErrorTrap

  ' some code goes in here

  CALL Proc2

  ' some more code goes in here

 

Proc1Resume:

  EXIT SUB

 

ErrorTrap:

  ' Error-handling code goes in here

  RESUME Proc1Resume

END SUB

 

See Also

Error Overview

Error Trapping

Setting an error trap

Writing an error handler

Exiting an error handler

Error Trapping Summary