Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #79956 > unrolled thread

Re: When using a decorator exceptions raised reference the decorator not the function

Started byJean-Michel Pichavant <jeanmichel@sequans.com>
First post2014-10-30 14:24 +0100
Last post2014-10-30 14:24 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Re: When using a decorator exceptions raised reference the decorator not the function Jean-Michel Pichavant <jeanmichel@sequans.com> - 2014-10-30 14:24 +0100

#79956 — Re: When using a decorator exceptions raised reference the decorator not the function

FromJean-Michel Pichavant <jeanmichel@sequans.com>
Date2014-10-30 14:24 +0100
SubjectRe: When using a decorator exceptions raised reference the decorator not the function
Message-ID<mailman.15323.1414675466.18130.python-list@python.org>
----- Original Message -----
> From: "Peter Otten" <__peter__@web.de>
> To: python-list@python.org
> Sent: Thursday, 30 October, 2014 1:45:42 PM
> Subject: Re: When using a decorator exceptions raised reference the decorator not the function
> 
> Néstor Boscán wrote:
> 
> > I'm using Python 2.7 and I'm creating a class decorator that
> > extract
> > information from exceptions for logging purposes.
> > 
> > Everytime an exception is raised from the original function and I
> > extract
> > the origin of the exception with sys.exc_info() I get a reference
> > to the
> > line in the decorator where the function is called, not the line of
> > the
> > original function where the exception was raised.
> > 
> > Any ideas?
> 
> Please show us the code, preferably as a small self-contained
> example. Thank
> you.

+1 show us your decorator.

if you did something like:

try:

except Exception, e:
  # do something
  raise e


Then replace "raise e" by a bare "raise"


JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web