Branch options
- Last Updated: October 18, 2024
- 2 minute read
- OpenEdge
- Version 12.2
- Documentation
After a block performs its UNDO operation,
the AVM must determine what action to take next. ABL has the following set of branching (flow
of control) options:
-
RETRY— If a block is an iterating block, theRETRYaction repeats the iteration of the block.RETRYis useful when you want to give your users another chance to input correct data. -
LEAVE— Indicates that the AVM should exit the block and resume execution with the next statement. -
NEXT— Indicates that the AVM should exit the current iteration of a block and continue with the next iteration. If there is not another iteration, thenNEXTis the same asLEAVE. -
RETURN— Indicates that the AVM should exit the block and immediately exit the current routine. Execution resumes in the caller. If no caller exists, then the application terminates. TheRETURNstatement has many options and is discussed from an error handling perspective in RETURN ERROR. -
THROW— Indicates that the AVM should capture any error message in an error or stop object, exit the block, and raise the same condition again in the next enclosing block, if there is one, otherwise in the caller. The thrown object is then available in the outer block to be handled there.
Each block type has default branching behavior. The following table lists the default action by block type and by context.
| Block Type | Action if user input detected | Action otherwise |
|---|---|---|
DO TRANSACTION
|
RETRY
|
LEAVE
|
FOR EACH
|
RETRY
|
NEXT |
REPEAT
|
RETRY
|
LEAVE
|
CATCH |
THROW |
THROW
|
FINALLY |
THROW |
THROW |
| Routine-level blocks (for example, procedures, methods) |
RETRY
|
LEAVE
|
| Trigger procedure file |
RETURN ERROR
|
RETURN ERROR
|
| Block Type | Action |
|---|---|
DO TRANSACTION |
LEAVE |
FOR EACH |
LEAVE |
REPEAT |
LEAVE |
CATCH |
LEAVE |
FINALLY |
LEAVE |
| Routine-level blocks (for example, procedures, methods) | LEAVE |
| Trigger procedure file | LEAVE |
For STOP conditions, the block action is
to leave, but the condition is raised again in the outer, or calling block, by default. Even
though the condition is raised again, this is not the same thing as a THROW. With THROW, the error message is trapped
in an object and is only displayed if you catch it and display the message itself, or if the
error raised at the outer/upper level is not handled or thrown again. It is not displayed at
the statement where the error occurred. For STOP, the
default is to display any error message immediately, leave the block, and raise the condition
again in the outer/upper block. The message is only displayed once at the place where the
STOP condition occurred.