Ian Bicking: the old part of his blog

Another catch-all idiom

I often end up doing something like the following, especially while debugging/printlining:

except Exception, x:
    x.args += (value,)
    raise x

When used in a framework that logs exceptions, it's handy. Unfortunately, it loses any traceback from the munge() call on down. :(

Comment on Good catch all exceptions
by Robert Brewer


If you use just raise (instead of raise x) it should still work, but you won't lose the traceback (at least that's what my brief testing indicates).
# Ian Bicking