aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Warner <antarus@scriptkitty.com>2012-12-30 17:33:06 (GMT)
committerAlec Warner <antarus@scriptkitty.com>2012-12-30 17:33:06 (GMT)
commit523745a562104b7c89e29f9f3d284a9688343438 (patch)
tree7cd24dab8ccd2a5e4237e4df25fcded0d8dbe1fb
parentChange to GMT to meet RFC requirements and fix bug 430350 (diff)
downloadpackages-523745a562104b7c89e29f9f3d284a9688343438.zip
packages-523745a562104b7c89e29f9f3d284a9688343438.tar.gz
packages-523745a562104b7c89e29f9f3d284a9688343438.tar.bz2
Return 404s instead of 500s for many error cases.
-rw-r--r--web/controller.py11
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',