Re: Exception handling
Rune Allnor wrote:
[error handling for buggy input]
An immediate fix is one of several possibilities, but
by no means a certain event.
Some times I can invoke a handler, say, if the input is
provided via a GUI. If an error is detected, a window
pops up to alert the user of the problem, and ask him
to provide valid input.
At other times, I might test for small numbers in
a sequence that ought to be strictly ascending.
I might raise an exception to warn of "small"
intervals, and check some user settings database
to see if the user has sanctioned the use of very
At still other times, like in batch jobs, the
best option might be to just ail out.
I don't think you should put the error handling into the code then. Rather,
it seems similar to a program running in a debugger. Sometimes, the user
will tweak some values, in other cases they will only abort execution. I'd
say that if you have an invalid database, you send out a notification with
the exact location that is bogus and the reason why. The receiver then can
decide to fix the data (change a few values), abort execution (throw an
exception) or ignore the error (return).
I think, but I'm not sure, that other languages have 'recoverable
exceptions' or 'reflection' which achieve the same principle. Maybe
reading a bit about how they do it could give you the right inspiration.
Sator Laser GmbH
Gesch??ftsf??hrer: Ronald Boers Steuernummer: 02/858/00757
Amtsgericht Hamburg HR B62 932 USt-Id.Nr.: DE183047360
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]