First, let me point out that when an app quits as the result of an
unhandled exception, that is not a crash. The app is behaving as
designed.
The point of an exception is to represent an error that the method in
which it is raised does not know how to handle. For example,
consider the NilObjectException. When a method attempts to call a
method or use a property of a nil object reference, the REALbasic
framework knows that this is a problem. But it does not know how
best to handle it. The calling method may be in a better position to
know how to handle it, so the framework raises a NilObjectException.
Charles Yeomans
On Dec 2, 2006, at 4:08 PM, [EMAIL PROTECTED] wrote:
Now, this is kind of my personal opinion, but in the spirit of good
programming, I really don't like to use exceptions in the normal
execution of code. If you need to make sure a variable isn't Nil,
then by all means, make sure the variable isn't Nil first. Have
you noticed that Exception handlers can be vauge and hard to use at
times? Exception handlers are designed to be a last resort to
prevent your program from crashing and to at least give you the
chance to recover from something you haven't handled.
Personally, I have one exception handler in all my programs - in
the App.UnhandledException event, just to keep my programs from
simply crashing. Other than that, I make every effort to simply
avoid an error before it causes any weirdness. In most cases, it's
just adding another enclosing if-statement.
Error checking is something I don't think enough people take
seriously. RB makes it a little less painful with having soft
crashes, where it will close any binary streams, release memory,
and do a few other things if your program really does crash, but
the bottom line is, you, as the programmer are the one and only
person who has the best opportunity to prevent your program from
crashing.
There is no class or plugin that will prevent your program from
suffering from any conceivable error. In a way, what you're
looking for is RB. By all means, make sure the variable isn't Nil
before you use it. Think about all the possible outcomes of your
code. Take advantage of layered if-statements (but don't go crazy,
either). If you wrote a program that works half the time and
throws up Exceptions for the rest, then you're not done. Write
code that avoids problems. 99% of the time, it's easier to walk
around the can of paint rather than to kick it and then clean up
the mess.
- Andrew Keller
On Dec 2, 2006, at 3:12 PM, Claude Stone wrote:
I have found that including an exception statement in each routine
will direct me to the routine and then troubleshoot by
breakpoints. IE:
Exception
MsgBox "Unhandled exception error in routine xyz"
At 08:32 AM 12/2/2006, you wrote:
I'm sure that I'm not the only one who finds error trapping a
tedious
process. Does anyone know of any classes or plugins that will
help take
care of this automatically?
Any input would be appreciated!
RB5.5.5 and a mostly unused copy of 2006r2.
WinXP, 2.2 GHz, 2G RAM
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>