annotate a traceback

R

Robin Becker

I want to annotate a traceback in routine A which is raised in B. Useful
information in A is not available in B

I propose to use something like

def A(info):
try:
B()
except:
t,v,b=sys.exc_info()
v.args = (' '.join(map(str,v.args))+', info=%r' % info,)
raise

is this a reasonable approach?
 
D

Diez B. Roggisch

Robin said:
I want to annotate a traceback in routine A which is raised in B. Useful
information in A is not available in B

I propose to use something like

def A(info):
try:
B()
except:
t,v,b=sys.exc_info()
v.args = (' '.join(map(str,v.args))+', info=%r' % info,)
raise

is this a reasonable approach?

I think a custom exception that takes the old sys.exc_info() and
encapsulates it would be better. Java has this, and it allows you to convey
different information without losing the original traceback.

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top