Block Flow of Control and Condition Directives

The ON phrase is one of the ABL constructs used for altering the default error handling for basic blocks. For information on default error (condition) handling see Default Condition Handling. There is a variation of the ON phrase to control each of the ABL conditions:
  • ON ERROR
  • ON STOP
  • ON QUIT
  • ON ENDKEY

The ON phrase can be used on the following blocks:

Block type Examples
DO

(This includes all DO block variations: simple DO blocks, DO TRANSACTION, DO WHILE, and DO FOR)

DO ON STOP UNDO, LEAVE:

DO TRANSACTION ON ERROR UNDO, THROW:

FOR EACH FOR EACH Order ON ERROR UNDO, NEXT:
REPEAT REPEAT ON QUIT UNDO, LEAVE:
There can be multiple ON phrases on the same block, separated by white space. For example:
DO TRANSACTION ON ERROR UNDO, RETRY  
               ON STOP UNDO, LEAVE: 
END.

You cannot modify the error action on other blocks using the ON phrase. This includes:

  • Procedures (top-level or internal)
  • User-defined methods
  • User-defined property getter/setter blocks
  • Constructors/destructors
  • User-defined functions
  • UI trigger blocks
  • Database triggers (ON block with CREATE, DELETE, WRITE, or ASSIGN event)

However, there is a way to change the default error handling for most of these blocks, at a block or routine level. This is described in the section on Use UNDO, THROW.