* An ''untreated error'' in a program will cause execution to stop and an error message is displayed to the user, who can choose to continue (ignore the error - which could have unexpected results) or end the program.
* Use [[ON ERROR]] when your program performs operations that are likely to generate errors, like file access operations.
* [[ON ERROR]] statements can be in the main module code or in [[SUB]] or [[FUNCTION]] procedures.
* [[ON ERROR]] statements take precedence in the order they are encountered. It will also handle any subroutine errors.
* '''ON ERROR GOTO 0''' can be used to disable custom [[ON ERROR]] trapping and give default error messages.
:''Explanation:'' The ON ERROR statement is normally placed at the beginning of the main module code. Errhandle is the line label sub referred to in the statement. The handler prints the error code and attempts to use the next line of code using [[RESUME]] NEXT which is only used in error handling procedures. [[_ERRORLINE]] returns the program file's actual text line count found in the IDE.
: ''Explanation:'' The [[GOTO]] procedure must be in the main code area after [[END]] to avoid a [[RESUME]] error later. Use GOTO 0 to clear the ON ERROR set in the sub so that later errors are not handled by it.