Try OpenEdge Now
skip to main content
Error Handling
Raising errors with THROW : THROW with error objects
 

THROW with error objects

As part of the ON ERROR phrase, UNDO, THROW causes the AVM to undo the current transaction, suppress the display of system error messages, create and populate an error object, and throw that error object. Assuming that the errors are not handled within the current block, THROW directs the block enclosing the current block to handle the errors. In other words, it propagates the errors up the call stack. For example:
DO TRANSACTION ON ERROR UNDO, THROW:
    FIND FIRST Customer WHERE Customer.CustNum = 1000.
                                              /* Fails and raises error. */
END.
The THROW directive on the UNDO statement allows you to raise specific application errors in the block in which the statement occurs. For example:
IF CurrentTime > ClosingTime THEN
    UNDO, THROW NEW Progress.Lang.AppError("Can't take a delivery order
                                            after closing time.", 550).
In the preceding example, a Progress.Lang.AppError is created with parameters that add a message and a message number to the new object.
* THROW compared with RETURN ERROR