You can use ON ERROR UNDO, THROW to change the default error handling. This construct is beneficial since it is not possible to use an ON phrase on some block types, such as procedure or method blocks. It is also useful for handling conditions in a central location, rather than locally. For example, if you have a code module with many blocks that can fail, and there is no advantage to a local CATCH block, and the error handling code is the same for all blocks in the module, then you can THROW all the errors up the call stack to a central location where a single CATCH statement can handle them all.

To take advantage of this more modern, structured error handling approach, you can change the default error directive to UNDO, THROW. Then errors propagate up by default so they can be handled by a common CATCH block. Exceptions can then be coded on specific blocks. To accomplish this, ABL provides two statements:
  • BLOCK-LEVEL ON ERROR UNDO, THROW
  • ROUTINE-LEVEL ON ERROR UNDO, THROW