DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Capture And Email A Traceback In Python

05.16.2006
| 6151 views |
  • submit to reddit
        
import traceback, smtplib, StringIO
fp = StringIO.StringIO()
traceback.print_exc(file=fp)
message = fp.getvalue()
server = smtplib.SMTP(FAILURE_SERVER)
server.sendmail(
  FAILURE_FROM,
  FAILURE_TO,
  FAILURE_MESSAGE + '\n\n' + message,
)
server.quit()
    

Comments

Snippets Manager replied on Mon, 2012/05/07 - 2:23pm

Fixed.

Snippets Manager replied on Mon, 2006/06/12 - 10:35am

you need to import StringIO