Try OpenEdge Now
skip to main content
ABL Essentials
Managing Transactions : Using the UNDO statement : Handling the ERROR condition
 

Handling the ERROR condition

Your application can encounter an error condition whenever the AVM cannot execute a statement properly, such as trying to find a record that does not exist or create a record with a duplicate value in a unique index. ABL has a built-in error message associated with each such error condition and, by default, displays it (or writes it to an error log on an AppServer).
For example, if your procedure executes a FIND statement for a nonexistent Customer, you get the error shown in the following figure.
Figure 58. FIND error message
The error number in parentheses lets you locate the message number under the Help menu to get more information on the error. It can also help you when you are reporting unexpected errors to technical support.
You can also generate the ERROR condition programmatically using the RETURN ERROR statement, either as part of the ON phrase of a block header or as a statement of its own. If your application has associated a keyboard key with the ERROR condition then the AVM also raises ERROR when the user presses that key.
Note: All of the error handling techniques described in this chapter are referred to as traditional error handling, and represent one valid way of accomplishing error handling. The ABL also has a new error handling model, introduced in OpenEdge Version 11.0, called structured error handling. Structured error handling represents system message as objects and provides you with the ability to write custom error handling code with the CATCH statement. The two models coexist and interoperate smoothly with one another. Both forms of error handling are fully documented in OpenEdge Development: Error Handling.
* ERROR-STATUS system handle
* Error handling
* RETURN statement and ON . . . RETURN phrase