ON ERROR RESUME NEXT
ON ERROR GOTO 0
Description
ON ERROR is used to allow error-handling in procedures, by catching fatal run-time errors and enabling continued execution. In the first form, RESUME NEXT, execution continues with the statement immediately following the statement where the error occurred. The second form, GOTO 0, is used to disable error-handling in the current procedure. If ON ERROR statements aren't used, any run-time error is fatal, displays an error message, and terminates execution.
Example
REM ON ERROR Example
'ON ERROR does error-handling in procedures
ADDOBJECT "File"
GetToDoList
SUB GetToDoList
ON ERROR RESUME NEXT
File.OPEN "ToDo", 1
IF ERR.NUMBER THEN
PRINT "Delayed ERROR handling"
PRINT "ERROR Source: " & ERR.Source
END IF
ON ERROR GOTO 0
END SUB
Output
Delayed ERROR Handling
ERROR Source: File
Related Items
Err Object