Gentoo Archives: gentoo-commits

From: Alec Warner <antarus@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] packages:master commit in: web/
Date: Sun, 30 Dec 2012 17:28:50
Message-Id: 1356888786.523745a562104b7c89e29f9f3d284a9688343438.antarus@gentoo
1 commit: 523745a562104b7c89e29f9f3d284a9688343438
2 Author: Alec Warner <antarus <AT> scriptkitty <DOT> com>
3 AuthorDate: Sun Dec 30 17:33:06 2012 +0000
4 Commit: Alec Warner <antarus <AT> gentoo <DOT> org>
5 CommitDate: Sun Dec 30 17:33:06 2012 +0000
6 URL: http://sources.gentoo.org/gitweb/?p=packages.git;a=commit;h=523745a5
7
8 Return 404s instead of 500s for many error cases.
9
10 ---
11 web/controller.py | 11 ++++++++++-
12 1 files changed, 10 insertions(+), 1 deletions(-)
13
14 diff --git a/web/controller.py b/web/controller.py
15 index 2275733..b4f5189 100644
16 --- a/web/controller.py
17 +++ b/web/controller.py
18 @@ -517,12 +517,21 @@ def database_connect():
19 sys.exit(1)
20 return database
21
22 +def handle_error():
23 + """Handle any unhandled exceptions.
24 + It turns out a lot of our code raises exceptions that cause 500's for users
25 + Instead of raising a 500 (for say, an invalid atom) simply return a 404
26 + instead. The exception should still get logged.
27 + """
28 + cherrypy.response.status = 404
29 +
30 def main():
31 """Use this when we run standalone"""
32
33 # site-wide config
34 cherrypy.config.update({
35 #'environment': 'production',
36 + 'response.error_response' = handle_error,
37
38 'log.screen': True,
39 'log.error_file': '/tmp/cherrypy_packages2.gentoo.log',
40 @@ -575,7 +584,7 @@ def setup_server():
41 # if something goes wrong, we get a log.
42 cherrypy.config.update({
43 #'environment': 'production',
44 -
45 + 'response.error_response' = handle_error,
46 'log.screen': False,
47 'log.error_file': '/tmp/cherrypy_packages2.gentoo.log',