Mark Donald wrote:
> I frequently have this situation:
>
> try:
> try:
> raise Thing
> except Thing, e:
> # handle Thing exceptions
> raise
> except:
> # handle all exceptions, including Thing
This seems like an unusual pattern. Are you sure you can't use
try
Mark Donald wrote:
Thanks for the idea, but I believe it has a different outcome. You'd
have to copy the generic handler into an except clause to get exactly
the behaviour I'm looking for, which is worse than nesting the try
blocks
Then simply change Exception to BaseException. Since all excep
Hrvoje Niksic wrote:
> How about:
>
> try:
> ... code that can raise Thing or another exception ...
> except Exception, e:
> if isinstance(e, Thing):
> # handle thing
> # generic exception handling
That is indeed the idiomatic way of handling the original poster's use
case wit
Mark Donald wrote:
I frequently have this situation:
try:
try:
raise Thing
except Thing, e:
# handle Thing exceptions
raise
except:
# handle all exceptions, including Thing
How about:
try:
... code that can raise Thing or another exception ...
except Ex
I frequently have this situation:
try:
try:
raise Thing
except Thing, e:
# handle Thing exceptions
raise
except:
# handle all exceptions, including Thing
It would be much more readable if there were a way to recatch a named
exception with the generic (catch-all