annotate a traceback

Discussion in 'Python' started by Robin Becker, Oct 29, 2009.

  1. Robin Becker

    Robin Becker Guest

    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
    Robin Becker, Oct 29, 2009
    #1
    1. Advertising

  2. 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
    Diez B. Roggisch, Oct 29, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ALuPin

    Back-Annotate Assignments

    ALuPin, Oct 20, 2004, in forum: VHDL
    Replies:
    1
    Views:
    1,769
    Ben Twijnstra
    Oct 20, 2004
  2. John Baima

    Annotate a floor plan

    John Baima, Jan 19, 2007, in forum: ASP .Net
    Replies:
    5
    Views:
    2,887
    John Baima
    Jan 24, 2007
  3. Jack Bates
    Replies:
    0
    Views:
    265
    Jack Bates
    May 2, 2011
  4. otown

    wrap text with annotate

    otown, Dec 28, 2006, in forum: Ruby
    Replies:
    1
    Views:
    106
    Eric Hodel
    Dec 28, 2006
  5. Aaron Dalton

    PerlMagick, Annotate, and Webdings

    Aaron Dalton, Mar 5, 2005, in forum: Perl Misc
    Replies:
    5
    Views:
    248
    Ron Savage
    Mar 27, 2005
Loading...

Share This Page