News for hackers. Stuff that matters.
Re:A Manifesto For Error Reporting by praptak on Tuesday March 05, 2013 @09:33AM (#5324643)
Python specific advice on re-raising upon catching and keeping the original trace: in Python 2.7+, please use chained exceptions: http://www.python.org/dev/peps/pep-3134/

For older Python versions please see http://blog.ianbicking.org/2007/09/12/re-raising-exceptions/

Re:A Manifesto For Error Reporting by masklinn on Tuesday March 05, 2013 @02:27PM (#5326721)
> For older Python versions please see http://blog.ianbicking.org/2007/09/12/re-raising-exceptions/

This is super important, I recently rediscovered this with a colleague (the company's tool was fucking up exceptions everywhere, either over-logging things or throwing stacktraces out in an attempt to rewrap them and we decided to fix this).

Although the second-to-last example:

    new_exc = Exception("Error in line %s: %s"
                    % (lineno, exc or exc_class))
    raise new_exc.__class__, new_exc, tb
would be much better written as:

    raise Exception, "Error in line %s: %s" % (lineno, exc or exc_class), tb