[CentralOH] Missing Exceptions?
brian.costlow at gmail.com
Tue Dec 13 22:24:13 CET 2011
You can look at the doc for the module in question, or just trawl the
But that might not even help, because the source will show you exceptions
the module explicitly raises, but not all the ones that code the module
calls might raise.
But IMHO the zen of exceptions is to catch the ones you can handle and do
something about at a given point.
Otherwise, let them bubble up to something that can, especially if you're
writing module/library code that calls modules that you didn't write.
Even if you are writing an app, probably better to just catch what you can
handle in local try blocks, let everything else bubble, and catch anything
not handled elsewhere in main just so you can exit the app with a graceful
message to the user instead of dumping a stack trace.
On Tue, Dec 13, 2011 at 3:30 PM, <jep200404 at columbus.rr.com> wrote:
> I wrote:
> except (ValueError):
> Later I realized that I had missed an exception,
> so the code was updated to:
> except (ValueError, TypeError): # !!! What exception names am I
> How does one determine what all the relevant exceptions are?
> How does one conclude that the the list of exceptions is complete?
> Those questions are general, about all try/except stuff,
> not just my little example.
> CentralOH mailing list
> CentralOH at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the CentralOH