[Tutor] Catching different exceptions [Exceptions]
Danny Yoo
dyoo@hkn.eecs.berkeley.edu
Tue, 12 Feb 2002 16:25:40 -0800 (PST)
On Tue, 12 Feb 2002, Danny Yoo wrote:
> Not that this isn't bad --- it's just that we often want to be able to
^^^^^^^^^^^^^^^^^^^^^^^
> look at the errors in more detail.
Gaaah! Holy moley, that was bad phrasing! I meant to say:
"Not that this is bad..."
I think that having catchall exception handling is ok, as long as we
somehow send the user a good error message that can help us debug
things. That is, as long as we have something like:
###
try: ...
except Exception, e:
print "Something is wrong: take a look: %s" % e
###
is much better than:
###
try: ...
except Exception, e: pass
###
because the second doesn't even clue us into potential problems.
We had a discussion on catchall exceptions a few weeks ago, and I had
initially said that doing a catchall was evidence of lazy programming.
Alan Gauld explained that using such a catchall can be a good thing, and
gave good reasons for using it. After thinking about it for a while, I'm
leaning toward Alan's reasoning.