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

Example 3

In Example 3, after ERROR is raised, execution goes to the CATCH block, which re-throws the error. However, the FINALLY block executes before the error goes to the CATCH block associated with the procedure block:
DO ON ERROR UNDO, LEAVE:
FIND Customer 1000. /* Raises ERROR and execution goes to the 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. */
UNDO, THROW eSysError.
END CATCH.

FINALLY:
/* Your code */
MESSAGE "Inside FINALLY block." VIEW-AS ALERT-BOX BUTTONS OK.
END FINALLY.

END. /* DO */

CATCH eSysError AS Progress.Lang.SysError:
MESSAGE "Out of DO block and inside CATCH block for procedure block"
VIEW-AS ALERT-BOX BUTTONS OK.
END CATCH.
If you run this code, you see the following messages: