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

Example 2

In Example 2, after ERROR is raised, execution goes to the CATCH block and then to the FINALLY block.
DO ON ERROR UNDO, LEAVE:
FIND Customer WHERE CustNum = 1000. /* Raises ERROR and execution goes to
                                         CATCH block. */

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

CATCH eSysError AS Progress.Lang.SysError:
/* Handler code for SysError condition */
MESSAGE "Inside CATCH block." VIEW-AS ALERT-BOX BUTTONS OK.
/* Execution goes to FINALLY before leaving DO block. */
END CATCH.

FINALLY:
/* Your code */
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: