Error Handling (V26)
ON ERROR GOTO
Syntax:
ON ERROR GOTO labelRedirects runtime errors to a label. Use ERR and ERL to inspect the error.
ON ERROR GOTO failed
' ... code that may error ...
EXIT FUNCTION
failed:
PRINT "Error "; ERR; " at line "; ERL
ERRCLEAR
RESUME NEXT
ON ERROR RESUME NEXT
Syntax:
ON ERROR RESUME NEXTIgnores errors and continues execution at the next statement.
ON ERROR RESUME NEXT x = 1 / 0 ' Division by zero ignored PRINT "continues"
ON ERROR GOTO 0
Syntax:
ON ERROR GOTO 0Disables error trapping. Errors terminate the program.
ERR
Syntax:
ERRReturns the last runtime error number.
ERL
Syntax:
ERLReturns the line number of the last runtime error.
ERRCLEAR
Syntax:
ERRCLEARClears the current error state. Sets ERR to zero and clears the error flag.
ERROR n
Syntax:
ERROR nTriggers a runtime error with code n. If no error handler is active, the program terminates.
ERROR 9 ' Trigger subscript error
RESUME / RESUME NEXT
Syntax:
RESUME | RESUME NEXTRESUME retries the statement that caused the error. RESUME NEXT continues after it. Must be called from within an error handler.
failed:
PRINT "Error handled"
ERRCLEAR
RESUME NEXT