summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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):