diff options
author | Alec Warner <antarus@scriptkitty.com> | 2012-12-30 09:33:06 -0800 |
---|---|---|
committer | Alec Warner <antarus@scriptkitty.com> | 2012-12-30 09:33:06 -0800 |
commit | 523745a562104b7c89e29f9f3d284a9688343438 (patch) | |
tree | 7cd24dab8ccd2a5e4237e4df25fcded0d8dbe1fb | |
parent | Change to GMT to meet RFC requirements and fix bug 430350 (diff) | |
download | packages-3-523745a562104b7c89e29f9f3d284a9688343438.tar.gz packages-3-523745a562104b7c89e29f9f3d284a9688343438.tar.bz2 packages-3-523745a562104b7c89e29f9f3d284a9688343438.zip |
Return 404s instead of 500s for many error cases.
-rw-r--r-- | web/controller.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/web/controller.py b/web/controller.py index 2275733..b4f5189 100644 --- a/web/controller.py +++ b/web/controller.py @@ -517,12 +517,21 @@ def database_connect(): sys.exit(1) return database +def handle_error(): + """Handle any unhandled exceptions. + It turns out a lot of our code raises exceptions that cause 500's for users + Instead of raising a 500 (for say, an invalid atom) simply return a 404 + instead. The exception should still get logged. + """ + cherrypy.response.status = 404 + def main(): """Use this when we run standalone""" # site-wide config cherrypy.config.update({ #'environment': 'production', + 'response.error_response' = handle_error, 'log.screen': True, 'log.error_file': '/tmp/cherrypy_packages2.gentoo.log', @@ -575,7 +584,7 @@ def setup_server(): # if something goes wrong, we get a log. cherrypy.config.update({ #'environment': 'production', - + 'response.error_response' = handle_error, 'log.screen': False, 'log.error_file': '/tmp/cherrypy_packages2.gentoo.log', |