On 6/09/2013 5:14am, Ben Finney wrote:
Brian May <[email protected]> writes:
On 5 September 2013 14:48, Ben Finney <[email protected]> wrote:
Why is it a problem for the exception to be raised within the bowels
of your program? I'm not saying there can't be a reason, but you
haven't said what the problem is.
The earlier you catch the error, the faster you can debug the source
problem and fix it.
Yes, failing earlier is better when you're trying to identify a problem.
But “earlier� here means “earlier in the testing process�.
A bug raised from deep within the program can provide *more* specific
information, helping to trace the assumptions being made at the various
levels of the program and informing your debugging efforts.
So I'll agree that it's important to *catch* errors at a high enough
level to provide context. But it's also important for the error to be
*raised* from whatever level of the code actually triggers the fault —
which is often deep within the bowels of the program, making that a
*good* place to raise the error.
Have had many cases where an error in a parameter to a function
doesn't show up until sometime later after the function has returned,
making it very hard to find out what the error was.
Someone mentioned errors occurring after hours of running. To cope(*)
with that I would throw elegance to the wind and use logging to record
all exceptions without stopping the process.
* cope = remain sane
Mike
My response to that is to recommend better unit tests, better coverage
by those tests, and functions which do fewer things so each one is
easier to rule out as a source of the problem.
Worse still, there are some errors that will just give incorrect
results without giving an error.
This is not an argument for type checking.
Much easier to catch the errors as soon as possible.
Agreed. None of that speaks against “errors from within the bowels of
the program�, though.
_______________________________________________
melbourne-pug mailing list
[email protected]
https://mail.python.org/mailman/listinfo/melbourne-pug