summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <lwirzenius@wikimedia.org>2019-07-04 17:10:56 +0300
committerLars Wirzenius <lwirzenius@wikimedia.org>2019-07-04 17:10:56 +0300
commit48af63bbb35835e08e1bacbdcfc19568e633704b (patch)
tree18b14eb107565723d044109bba8c03c81708fc6f
parent12faa927a76281af8f7361db64265bdec91dbc36 (diff)
downloadwmf-ci-arch-48af63bbb35835e08e1bacbdcfc19568e633704b.tar.gz
Change: catch exceptions from a wider area
-rwxr-xr-xapi.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/api.py b/api.py
index 7804f9d..47596b7 100755
--- a/api.py
+++ b/api.py
@@ -132,21 +132,21 @@ class API:
def check(self, func, required_scopes, kwargs):
'''Call a callback function, if it's OK to do so'''
- r = bottle.request
- logging.debug('New request, checking access: %s %s', r.method, r.path)
+ try:
+ r = bottle.request
+ logging.debug('New request, checking access: %s %s', r.method, r.path)
- if self._checker.access_is_allowed(r.headers, required_scopes):
- logging.info('Access is allowed: %s %s', r.method, r.path)
- try:
+ if self._checker.access_is_allowed(r.headers, required_scopes):
+ logging.info('Access is allowed: %s %s', r.method, r.path)
ret = func(**kwargs)
- except Exception as e:
- logging.warning('Caught exception: %s', str(e))
- return bottle.httpError(500)
- logging.info('Result: %r', ret)
- return ret
-
- logging.error('Request denied %s %s', r.method, r.path)
- return bottle.HTTPError(400)
+ logging.info('Result: %r', ret)
+ return ret
+
+ logging.error('Request denied %s %s', r.method, r.path)
+ return bottle.HTTPError(400)
+ except Exception as e:
+ logging.warning('Caught exception: %s', str(e))
+ return bottle.httpError(500)
class Controller(API):