Question Try Catch

AFAIK the structured error handling was introduced somewere around OpenEdge 10.1. I did use OpenEdge 10.1c and that version did support it.
 
there's a try/catch/finally in the progress standard libraries at the oehive.org that's compatible with version 9 or higher.

the progress try catch is pretty rigid anyways.

Code:
{slib/sliberr.i}

define var cError as char no-undo.
define var cErrorMsg as char no-undo.

{slib/err_try}:

    run something {slib/err_no-error}. /* you can also use {slib/err_throw "'<exception name>'" [params]}. */

    /* you can use nested try blocks for as many levels as you'd like */

{slib/err_catch cError cErrorMsg}: /* catch is optional */

    message cErrorMsg.

    /* you can use {slib/err_throw last}. to retrhow the catched error */

{slib/err_finally}: /* finally is optional */

    message "finally".

{slib/err_end}.

message "after",

hth
 
Last edited:
As joey wrote, those includes are from oehive.org.
With 10.2b you could use the built-in throw/catch/finally features. Some things to keep in mind:
- Mixing the old (on error ...) and new error handling can yield strange or unexplainable results.
- You can use
routine-level on error undo, throw.
or
block-level on error undo, throw.
at the beginning of a program file if you want the new error handling to apply without writing it every time.
- catch doesn't catch stop conditions. You will still need "on stop ..." somewhere.
- catch suppresses the output of error messages as opposed to "on error", unless you re-throw the exception. It might be necessary to display the caught exceptions manually, otherwise looking for an error may get very difficult.
 
Thank you for the correction. We started using ROUTINE-LEVEL in our product with OE 11, BLOCK-LEVEL is planned AFAIR.
(I don't write the statement myself, it is in our templates.)
 
Oops yes RHD is correct. Seriously worried at the state of my brain at the moment.
 
Back
Top