Brian May <br...@microcomaustralia.com.au> writes:

> On 5 September 2013 14:48, Ben Finney <ben+pyt...@benfinney.id.au> 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.

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.

-- 
 \        “I don't accept the currently fashionable assertion that any |
  `\       view is automatically as worthy of respect as any equal and |
_o__)                                   opposite view.” —Douglas Adams |
Ben Finney

_______________________________________________
melbourne-pug mailing list
melbourne-pug@python.org
https://mail.python.org/mailman/listinfo/melbourne-pug

Reply via email to