diff options
author | Lars Wirzenius <lwirzenius@wikimedia.org> | 2019-07-04 17:10:56 +0300 |
---|---|---|
committer | Lars Wirzenius <lwirzenius@wikimedia.org> | 2019-07-04 17:10:56 +0300 |
commit | 48af63bbb35835e08e1bacbdcfc19568e633704b (patch) | |
tree | 18b14eb107565723d044109bba8c03c81708fc6f | |
parent | 12faa927a76281af8f7361db64265bdec91dbc36 (diff) | |
download | wmf-ci-arch-48af63bbb35835e08e1bacbdcfc19568e633704b.tar.gz |
Change: catch exceptions from a wider area
-rwxr-xr-x | api.py | 26 |
1 files changed, 13 insertions, 13 deletions
@@ -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): |