ABL condition handling
- Last Updated: October 18, 2024
- 2 minute read
- OpenEdge
- Version 12.2
- Documentation
Default condition handling exists for any condition that occurs in an application. This is explained in more detail in Default Condition Handling. However for most applications, the default handling does not provide the most desirable way to control program flow or show error messages in a user-friendly manner. Therefore, most applications customize how conditions are handled.
Below is a summary of the various ABL constructs that can be used to customize condition handling. Each is discussed in more detail in later sections.
- The
NO-ERRORkeyword — This is useful when an error is expected on a single statement and there is a specific programmatic way of handling it. - The
ONphrase on a block — This includesON ERROR,ON STOP,ON QUIT, andON ENDKEY. These are used to determine program flow after an unexpected condition, or to throw the condition to a higher level to be handled there. CATCHblocks — This is the most desirable way to deal with unexpectedERRORandSTOPconditions. It gives the program access to error information so that it can be reported in a customized way.- Error objects — The ABL provides a set of built-in objects representing
ERRORorSTOPconditions, which can be caught. In addition, applications can create their own application error objects that can be thrown and may provide extra contextual information. - The
UNDO, THROWstatement — This is a way to rethrow a caught error or stop object, or throw an application error object. FINALLYblocks — This is not specifically about handling conditions. However, it allows you to write code that always runs at the end of a block, whether a condition occurs in that block or not.