summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <lwirzenius@wikimedia.org>2019-07-04 17:08:51 +0300
committerLars Wirzenius <lwirzenius@wikimedia.org>2019-07-04 17:08:51 +0300
commit12faa927a76281af8f7361db64265bdec91dbc36 (patch)
tree5a2e5170f272c70a38cf02cb15b363ec3b803aa1
parent6189206577786426b97fcbb7f84f1a06caf0c9cf (diff)
downloadwmf-ci-arch-12faa927a76281af8f7361db64265bdec91dbc36.tar.gz
Add: catch exceptions inside callback too
-rwxr-xr-xapi.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/api.py b/api.py
index bbdc7d7..7804f9d 100755
--- a/api.py
+++ b/api.py
@@ -137,7 +137,11 @@ class API:
if self._checker.access_is_allowed(r.headers, required_scopes):
logging.info('Access is allowed: %s %s', r.method, r.path)
- ret = func(**kwargs)
+ try:
+ 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