What's he up to?
Mail uncaught errors with Google App Engine
From Kees van den Broek. February 28, 2010, 1 Comment
A simple script to start off any new GAE project.
All exceptions raised in production will show up in the GAE Logs dashboard, but I prefer to be notified by email.
To prevent email flooding, the same error will only be reported once a day.
class SomeHandler(EmailRequestHandler): def get(self): # Any unhandled exception here will be mailed.
import traceback from google.appengine.ext import webapp from google.appengine.api import memcache, mail class EmailRequestHandler(webapp.RequestHandler): """Mail admins on uncaught exceptions. Send the same exception only once (per day) """ def handle_exception(self, exception, debug_mode): tb = traceback.format_exc() already_reported_tb = memcache.get(tb) if already_reported_tb is None: memcache.add(tb, '1', 60 * 60 * 24) mail.send_mail_to_admins(sender="admin@mydomain.com", subject="Exception catch-all triggered", body=tb) webapp.RequestHandler.handle_exception(self, exception, debug_mode)
It would be nice to programmatically add the GAE project name as well…
One Response to “Mail uncaught errors with Google App Engine”
Leave a Reply
last modified on 2010-02-23 @ 15:10
Buy:Viagra Super Force.Cialis Soft Tabs.Maxaman.VPXL.Zithromax.Cialis.Viagra Soft Tabs.Cialis Professional.Super Active ED Pack.Soma.Viagra Super Active+.Viagra.Cialis Super Active+.Levitra.Propecia.Viagra Professional.Tramadol….