change an exception's message and re-raise it
Phlip
phlip2005 at gmail.com
Fri Jan 1 10:10:51 EST 2010
On Dec 31 2009, 4:30 pm, Steven D'Aprano <st... at REMOVE-THIS-
cybersource.com.au> wrote:
> ... 1/0
> ... except ZeroDivisionError, e:
> ... e.args = e.args + ('fe', 'fi', 'fo', 'fum')
> ... raise
When I added print e.args it showed the old args. Maybe I was trying
too hard - this is why I said e seemed locked or something.
This started working:
new_exception = self.format_fault(e.args[0])
e.args = (new_exception,) + (e.args[1:])
raise
May I ask if args always has more than one entry? I need to bypass the
silly "'tuple' object does not support item assignment" issue...
More information about the Python-list
mailing list