I want to achieve something like this:

def foo():
   try:
       raise IOError('Stuff ')
   except:
       raise

def bar(arg1):
    try:
       foo()
    except Exception as e:
       e.message = e.message + 'happens at %s' % arg1
       raise

bar('arg1')
Traceback...
  IOError('Stuff Happens at arg1')

But what I get is:

Traceback..
  IOError('Stuff')

Any clues as to how to achieve this? How to do it both in Python 2 and 3?

12 Answers
12

Leave a Reply

Your email address will not be published. Required fields are marked *