From 12faa927a76281af8f7361db64265bdec91dbc36 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Thu, 4 Jul 2019 17:08:51 +0300 Subject: Add: catch exceptions inside callback too --- api.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 -- cgit v1.2.1