Try OpenEdge Now
skip to main content
Error Handling
Traditional Error Handling : Providing custom error handling : Testing for statement errors
 

Testing for statement errors

The next example presumes that you want to execute special business logic if a particular system error message occurs. The NO-ERROR option suppresses the standard ABL error handling and the IF statement queries the ERROR-STATUS system handle message numbers to see if the particular error message occurred, as shown:
DEFINE VARIABLE i AS INTEGER NO-UNDO.

FIND FIRST Customer WHERE CustNum = 1000 NO-ERROR.

IF ERROR-STATUS:ERROR THEN
DO i = 1 TO ERROR-STATUS:NUM-MESSAGES:
IF ERROR-STATUS:GET-NUMBER( i ) = 565 THEN
RUN FailedFindRecovery.p.
IF i = ERROR-STATUS:NUM-MESSAGES THEN
            RUN GeneralErrorRecovery.p.
END.