Most web apps have bugs. It’s just the way things are — you usually need to launch before you’re satisfied your latest startup is 100% bug-free, if there is such a thing. One of the nice things about a web app is that it’s easy to let your first users help you find bugs.
Both microPledge and DecentURL use Python and the minimalist web.py framework. It’s easy to set up web.py to show nice error tracebacks to the user (good for development), but it’s not a built-in feature to email real tracebacks to the site admins.
We’ve found emailed tracebacks particularly handy, so I thought I’d share the code. Nothing fancy, but it works well, and has proved invaluable for the live debugging of our own web applications. I’m not terribly familiar with other web frameworks, but I imagine the concept wouldn’t be too hard to port.
A couple of security notes:
- If your site’s at all sensitive, it’s important to serve up tracebacks via HTTPS and to check that the user viewing the page is an “admin” user. There’s lots of sensitive info in some of these tracebacks, including source snippets, database passwords, etc.
- This is why you don’t want to email the tracebacks as attachments directly — email is sent in the clear.
Anyway, have a look at the code: emailerror.py. It’s a stand-alone web.py WSGI app that shows you how to do it. Have fun!
20 November 2007 by Ben 4 comments