Hello there,
Question 1:
Do we really need to include ON ERROR UNDO, THROW on every DO ON ERROR, FOR EACH and REPEAT blocks to throw the error to the caller? Is there a simpler way?
Question 2:
Is there a simpler way of including ROUTINE-LEVEL ON ERROR UNDO, THROW. in every main procedure? Simpler than puting this in an include file also.
Thanks
On #1, you need to include it where ever you want to handle the errors. If the old-style error handling does the job for you, then you don't need to change it, but if you want the control and flexibility of structured error handling, then you need to add structured error handling! Don't you wish your code came from a code generator so that you could change the template and be done?
On #2, same rule ... if you want it, you have to add it.
Are you still coding in AppBuilder or using OpenEdge Architect already? OEA offers toggles in the new class/procedure and then new internal procedure/new method block that include the
ROUTINE-LEVEL ....
and a default CATCH and FINALLY block.
Between the lines of your post, I'm assuming you have been waiting for a startup parameter or other global setting that makes this change. I am personally happy, that this parameter is not available (not like the stupid -NL parameter)!
1.) The app would depend on that parameter - so missing it somewhere (when doing hot fixed on a production site) and the whole error handling might get screewed up.
2.) The behaviour of code should be clear from reading it... Adding compile time startup parameters is outside the bounds of the source code. No good! And error handling is really a critical part of the behavior.
3.) You can mix old and new error handling in one app. Works great - but for every code unit you need to decide which way to handle errors...
Hi Mike. I am using Architect 10.1C. Yes I do see the toggle defaults when adding a new procedure or internal procedure. I cannot find a suggestion regarding an automatic/defaulting to ON ERROR, UNDO THROW but I can put it in my editor template. Danke shune.
To get a standard block error handling on new code, consider going to Preferences, OpenEdge Architect, Editor, Templates and defining a macro to put in your standard error clauses.
Housecleaning.