Keep Error Information is a method of
TacticalTesting.
How many times have you written code that notices some bizarre condition
that cannot possibly be valid, so you decided to bail out and abort the
current operation?
Fair enough, but what did you do about the problem?
Did you just tell the user that there was an internal error and forget
about it?
Well that was naughty.
That bizarre condition may only occur rarely, but it means your code is
not working and if you don't fix it now you will fix it later.
So you'd might as well keep as much information as you know now.
That means, you DO NOT record that error number 78 happened.
Error codes are an absolute curse, simply designed to keep errors in
the code, not to get them out.
You package up every fact you know about the exception and you write it
down where the experts can find it (
ReportBugsSilently).
Maybe after it has happened a few times you will notice a pattern and
be able to fix it.
Another place where error information gets lost is when you wrap
exceptions.
Just say you try some complex operations.
You probably catch a couple of exceptions that you expect to get,
and you either rethrow them, handle them, or wrap them in another
exception which explains what happened.
However for all other exception types (particularly
RuntimeException),
you catch the exception and rethrow it as an internal failure.
That exception you just lost the info from was the best story you
ever heard about the bugs in your code.
Please make sure before you throw it away that you record it for
debugging purposes!
--
JohnFarrell