Try OpenEdge Now
skip to main content
Error Handling
Introduction to Condition Handling : Traditional error handling : Application error handling
 

Application error handling

You can raise the ERROR condition yourself with the RETURN ERROR statement and force the default error handling of the block to execute. The default error handling occurs after execution resumes in the caller.
You can also specify a character string with RETURN ERROR that represents your application error data. You access the returned string with the RETURN-VALUE function.
In the following example, the code suppresses the default error handling in both the internal procedure and in the main procedure. It essentially replaces the standard error message and returns the custom message to the caller to be displayed after the RUN statement, as shown:
PROCEDURE Customer1000:

FIND FIRST Customer WHERE CustNum = 1000 NO-ERROR.

    IF ERROR-STATUS:ERROR = TRUE THEN
    RETURN ERROR "Customer 1000 does not exist in this database.".

END PROCEDURE.

RUN Customer1000 NO-ERROR.

IF ERROR-STATUS:ERROR = TRUE THEN
DISPLAY RETURN-VALUE FORMAT "x(60)".
ELSE DISPLAY "Procedure completed successfully." FORMAT "x(60)".