[CentralOH] Missing Exceptions?

Thomas Winningham winningham at gmail.com
Tue Dec 13 22:16:17 CET 2011


You should be able to capture anything that is a subclass of the Base
Exception, and then infer the type of exception from there. The only
real need for itemizing exceptions is when there is one you know will
happen that you have a solution for, so you want the operation of the
program to continue, but you want other exceptions to go ahead and not
be caught and then let the whole program fall on the floor at that
point.

If you want to just completely implement your own error handling as a
whole and allow operation to continue short of a segfault or some
other nasty bug or just running out of memory something, then you can
just catch any and all exceptions.

Sorry I don't have specific examples, but I wanted to provide a
general narrative around the concept. For a lot of other languages
that are strongly typed, you pretty much have to specify what
exceptions you are trapping for right? I guess I'm thinking Java,
maybe.

Anyway, best of luck, I'm sure someone else has some ideas?

On Tue, Dec 13, 2011 at 3:30 PM,  <jep200404 at columbus.rr.com> wrote:
> I wrote:
>
>    try:
>        float(s)
>    except (ValueError):
>
> Later I realized that I had missed an exception,
> so the code was updated to:
>
>    try:
>        float(s)
>    except (ValueError, TypeError):  # !!! What exception names am I missing?
>
> 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
> http://mail.python.org/mailman/listinfo/centraloh


More information about the CentralOH mailing list