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",
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.)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.