{"id":3060,"date":"2014-03-15T03:27:21","date_gmt":"2014-03-15T03:27:21","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/15\/catch-all-global-exception-handler-in-app-engine-for-python-collection-of-common-programming-errors-2\/"},"modified":"2014-03-15T03:27:21","modified_gmt":"2014-03-15T03:27:21","slug":"catch-all-global-exception-handler-in-app-engine-for-python-collection-of-common-programming-errors-2","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/15\/catch-all-global-exception-handler-in-app-engine-for-python-collection-of-common-programming-errors-2\/","title":{"rendered":"Catch-All global exception handler in App Engine for Python-Collection of common programming errors"},"content":{"rendered":"<p>Yes it is possible.<br \/>\nYou can do it using the ereporter package that allows to receive exception reports from your application by email.<\/p>\n<p>Ereporter will report two kind of exceptions:<\/p>\n<ul>\n<li>exceptions logged with <code>logging.exception('Your handled exception')<\/code><\/li>\n<li>any uncaught exceptions<\/li>\n<\/ul>\n<p>To catch all the exceptions, I would create a custom BaseHandler class overriding the handle_exception() method; all your request handlers should inherit from this Base class.<br \/>\nHave a look to Custom Error Responses too.<\/p>\n<p>Here is a simple example of BaseHandler class:<\/p>\n<pre><code>class BaseHandler(webapp.RequestHandler):\n\n    def handle_exception(self, exception, debug_mode):\n        if debug_mode:\n            webapp.RequestHandler.handle_exception(self, exception, debug_mode)\n        else:\n            logging.exception(exception)\n            self.error(500)\n            self.response.out.write(template.render('templdir\/error.html', {}))\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Yes it is possible. You can do it using the ereporter package that allows to receive exception reports from your application by email. Ereporter will report two kind of exceptions: exceptions logged with logging.exception(&#8216;Your handled exception&#8217;) any uncaught exceptions To catch all the exceptions, I would create a custom BaseHandler class overriding the handle_exception() method; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3060","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3060","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3060"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3060\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3060"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3060"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3060"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}