On Thu, Nov 15, 2012 at 9:02 AM, Paul Wiseman <poal...@gmail.com> wrote:
> I was just looking at some logs and some of the errors logged without > tracebacks, I work out it was when I wasn't passing the error object to > log.err- Is this by design? > In Python 2.x, exception objects do not have any reference to their traceback; this is one of the reasons Twisted has the Failure class, which encapsulates both. (In Python 3 exceptions do have their tracebacks attached.) Thus, if you want the traceback logged, you should do something like: from twisted.python import log try: 1/0 except Exception as e: # Log the last exception that occurred, including its traceback: log.err(None, "An error occurred.") Or: from twisted.python import log, failure try: 1/0 except Exception as e: f = failure.Failure() log.err(f, "An error occurred.") -- Itamar Turner-Trauring, Future Foundries LLC http://futurefoundries.com/ — Twisted consulting, training and support.
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python