BLOCK-LEVEL ON ERROR UNDO, THROW statement
- Last Updated: October 18, 2024
- 2 minute read
- OpenEdge
- Version 12.2
- Documentation
The BLOCK-LEVEL ON ERROR UNDO, THROW
statement changes the default implicit ON ERROR phrase to
ON ERROR UNDO, THROW for every supported block type in the
file that contains the statement. This is specifically for ERROR, not
STOP conditions because STOP conditions are already
thrown by default. The following blocks are affected by this statement:
- Procedure (also called main block, external procedure, or .p file, including database trigger .p files)
- Internal procedure
- Database trigger (
ONblock withCREATE,DELETE,WRITE, orASSIGNevent) - User-defined function
- Constructor
- User-defined method
- User-defined property getter/setter
-
REPEAT -
FOR -
DO TRANSACTION
The following blocks are not affected:
- Any block for which an error-handling directive is explicitly specified
- Simple
DOblock DO WHILEblock- Destructor
- UI trigger
Syntax
|
The following rules affect the placement of
the BLOCK-LEVEL ON ERROR UNDO, THROW statement:
- The statement occurs once in each source file in which the behavior is desired.
- The statement must come before any definitional or executable statement in the procedure or class file.
- The statement can come before or after a
USINGstatement.
Example
To create an application that uses structured error handling to handle all uncaught local errors at the top level:
- Include the
BLOCK-LEVEL ON ERROR UNDO, THROWstatement in all your procedure and class files. - For each basic block, decide whether a different explicit flow of control directive is appropriate.
- Add a
CATCHblock for theProgress.Lang.Errorinterface to your startup procedure block. For more information, see CATCH Blocks. - Add a
CATCHblock locally for any errors you want to handle at a local level.
The following simple example illustrates the design pattern:
|