Use the ON ERROR command to execute a command if an error occurs.
Options
command
Specifies the command to run when an error occurs.
RESET
Turns ON ERROR processing off.
About the ON ERROR Command
The default is ON ERROR RESET.
Any command that can be used in an entry/exit procedure (EEP) can be used with ON ERROR except: TRACE, form specific commands such as NEXTROW, SKIP, etc., and commands more than 2000 characters long. If a command can't be used in an EEP, such as DROP, CREATE, CONNECT, and DISCONNECT, it can't be used with ON ERROR.
Since this command remains in effect until it is re-issued, you should place ON ERROR RESET at the end of command files that use it. If ON ERROR runs a command file, the file must end with a RETURN command.