Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1diff --git a/src/oncall/app.py b/src/oncall/app.py 2index 370fcf4..59f014e 100644 3--- a/src/oncall/app.py 4+++ b/src/oncall/app.py 5@@ -62,9 +62,19 @@ class AuthMiddleware(object): 6 7 application = None 8 9+def handle_uncaught_exception(req, resp, ex, params): 10+ logging.exception('Unhandled error') 11+ raise falcon.HTTPInternalServerError(title='App error') 12+ 13+ 14+def handle_http_error(req, resp, ex, params): 15+ logging.exception('HTTP error') 16+ raise ex 17+ 18 19 def init_falcon_api(config): 20 global application 21+ 22 cors = CORS(allow_origins_list=config.get('allow_origins_list', [])) 23 middlewares = [ 24 SecurityHeaderMiddleware(), 25@@ -74,6 +84,8 @@ def init_falcon_api(config): 26 if config.get('require_auth'): 27 middlewares.append(AuthMiddleware()) 28 application = falcon.App(middleware=middlewares) 29+ application.add_error_handler(falcon.HTTPError, handle_http_error) 30+ application.add_error_handler(Exception, handle_uncaught_exception) 31 application.req_options.auto_parse_form_urlencoded = False 32 application.set_error_serializer(json_error_serializer) 33 application.req_options.strip_url_path_trailing_slash = True