Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > annotate a traceback

Reply
Thread Tools

annotate a traceback

 
 
Robin Becker
Guest
Posts: n/a
 
      10-29-2009
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?
--
Robin Becker

 
Reply With Quote
 
 
 
 
Diez B. Roggisch
Guest
Posts: n/a
 
      10-29-2009
Robin Becker wrote:

> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"raise (type, value, traceback)" and "raise type, value, traceback" Jack Bates Python 0 05-02-2011 05:23 PM
Annotate a floor plan John Baima ASP .Net 5 01-24-2007 05:22 PM
wrap text with annotate otown Ruby 1 12-28-2006 10:32 PM
Back-Annotate Assignments ALuPin VHDL 1 10-20-2004 09:21 PM
how to annotate photos? peter Digital Photography 12 07-24-2004 07:32 AM



Advertisments