Try OpenEdge Now
skip to main content
Error Handling
Using FINALLY End Blocks : Examples : Example 1
 

Example 1

In Example 1, the FINALLY block executes before any flow-of-control (LEAVE, NEXT, RETRY, RETURN, or THROW) options are executed for the associated block. For iterating blocks, the FINALLY block executes after each iteration of the block:
DO ON ERROR UNDO, LEAVE:
  FIND Customer WHERE CustNum = 1000. /* Raises ERROR and execution goes to
                                         FINALLY block before the LEAVE option
                                         executes */

MESSAGE "This message never appears because of ERROR condition."
    VIEW-AS ALERT-BOX BUTTONS OK.

FINALLY:
MESSAGE "Inside FINALLY block." VIEW-AS ALERT-BOX BUTTONS OK.

/* LEAVE DO block here */
END FINALLY.

END. /* DO */

MESSAGE "Out of DO block." VIEW-AS ALERT-BOX BUTTONS OK.
If you run this code, you see the following messages: