On Mon, Dec 31, 2012 at 2:31 PM, Art Heimsoth <artst...@artheimsoth.com>wrote:
> What is the best way to intercept the major errors when using ooDialog?
>
Hi Art,
That depends on what you mean by major errors. What errors are you seeing
that you want to intercept?
This is sort of tongue in cheek, but it is actually my opinion. The best
way is to not have major errors.
> I have tried the signal on ERROR and signal on FAILURE, with the name label
> in my method within the main class that does the cleanup, but that does not
> seem to work in that if the signal is raised, the label is not found, but
> for
> several errors, the signal is not raised either - or I have the signal
> statement
> in the incorrect place. I have it located at the beginning of the
> InitDialog
> method.
>
I confess I do not understand the signal on functionality real well.
Having said that, I can still say, if you locate the signal statement in
initDialog, you will only get the signal if the condition occurs in the
initDialog() method. This is generally true for any method.
This makes it difficult to use signal effectively in ooDialog.
In the older ooDialog examples, they had signal handling code in the main
portion of an ooDialog program. The generic format of this was:
/* Install signal handler to catch error conditions and clean up */
signal on any name CleanUp
MyDialog = .MyDialogClass~new
if MyDialog~InitCode = 0 then do
rc = MyDialog~Execute("SHOWTOP")
end
exit
/* -- signal handler to destroy dialog if error condition was raised -*/
CleanUp:
call ErrorMessage "Error" rc "occurred at line" sigl":" errortext(rc),
|| "a"x || condition("o")~message
if MyDialog~IsDialogActive then MyDialog~cancel
In my opinion, this code is worse than useless. Many, if not most, of the
errors that might occur during the execution of the dialog will not be
trapped. If an error is trapped before the underlying dialog is created,
than the IsDialogActive() method will not be good:
72 *-* if MyDialog~IsDialogActive
Error 97 running C:\Rexx\ooRexx.3.0.1.release\samples\oodialog\oodtree.rex
line 72: Object method not found
Error 97.1: Object "MYDIALOG" does not understand message "ISDIALOGACTIVE"
And, the report of the error that is trapped will say it happened on line
58, in this case. For the example program I'm using. Line 58 is this line:
rc = MyDialog~Execute("SHOWTOP")
The error was actually, in this case, on line 168.
So, in all cases, the line reported is not going to be where the error
actually was. The signal handling code essentially hides the real error.
Because of this, I'm removed that code from the examples in the current
version of ooDialog.
In the current implementation of ooDialog, syntax errors are raised in some
places when incorrect usage is detected.
This is 99.9 % of all the errors I see. My opinion is you do not want to
trap those errors. You write an ooDialog program. The first time you run
the program, from the command line, to test it, you get a syntax condition
raised. The print out in the command window tells you exactly where the
error is. You fix your incorrect usage and test the program again.
Once your fix your incorrect usage, the error never happens again. Trying
to trap the error only prolongs the amount of time that your program does
not work correctly.
So, my only question left, is what type of errors are you seeing that you
want to trap?
--
Mark Miesfeld
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122412
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users