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 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 0Disables error trapping. Errors terminate the program.
ERRReturns the last runtime error number.
ERLReturns the line number of the last runtime error.
ERRCLEARClears the current error state. Sets ERR to zero and clears the error flag.
ERROR nTriggers a runtime error with code n. If no error handler is active, the program terminates.
ERROR 9 ' Trigger subscript error
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