Try OpenEdge Now
skip to main content
Error Handling
Traditional Error Handling : Suppressing errors
 

Suppressing errors

The NO-ERROR option on an ABL statement suppresses all ABL error handling. For example:
*No message is displayed to the default output
*Execution will continue with the next statement
*Control is not redirected to the block error handling
Note: The NO-ERROR option has no effect on STOP condition handling.
Refer to OpenEdge Development: ABL Reference to see what particular statements support the NO-ERROR option. In some cases, the standard NO-ERROR option behavior may be augmented to suit a particular statement.
If an error occurs when the NO-ERROR option is present, the action of the statement is not done and execution continues with the next statement. If the statement fails, any persistent data updates of the statement are backed out. If the statement includes an expression that contains other executable elements, like methods, the work performed by these elements may or may not be done, depending on the order the AVM resolves the expression elements and the occurrence of the error.
In this example, the internal procedure returns to the calling procedure block with the ERROR condition raised. However, the RUN statement includes the NO-ERROR option. The final DISPLAY statement executes because the AVM handles the ERROR condition, as shown:
PROCEDURE NestedBlocks:

Outer-Block:
    FOR EACH Customer WHERE CustNum < 5:
        ASSIGN Customer.Name = Customer.Name + "_changed".

Inner-Block:
        FOR EACH Order OF Customer
ON ERROR UNDO Outer-Block, RETURN ERROR:

DISPLAY OrderNum.

/* Nonsense code raises ERROR. */
FIND SalesRep WHERE RepName = Customer.Name.
END.
END.

DISPLAY "For Blocks Complete".
END PROCEDURE.

RUN NestedBlocks NO-ERROR.

DISPLAY "Procedure NestedBlocks Complete."
This example also demonstrates the scope of the NO-ERROR option, which applies only to the statement. Even though the RUN statement resulted in the routine being run, the statements contained in the routine are not affected by the NO-ERROR option.