Skip to content

Commit f2e2ae0

Browse files
committed
Add env var to add an exception logging errorhandler
1 parent b233a7c commit f2e2ae0

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ my-python:
305305

306306
- `MODE` to specify the deployment mode. Can be `development` as well as `production`. Defaults to `production`
307307

308+
- `LOG_EXCEPTIONS` set to any value to add a catch-all Flask errorhandler that logs exceptions rather than just returning them, to aid with debugging. Is not on by default in development as it may prevent custom errorhandlers in you app from being reached.
309+
308310
- `MU_SPARQL_ENDPOINT` is used to configure the SPARQL endpoint.
309311

310312
- By default this is set to `http://database:8890/sparql`. In that case the triple store used in the backend should be linked to the microservice container as `database`.

web.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
except Exception:
3333
helpers.logger.exception('Exception raised when importing app code')
3434

35+
if os.environ.get('LOG_EXCEPTIONS'):
36+
@app.errorhandler(Exception)
37+
def handle_exception(e):
38+
helpers.logger.exception('Unhandled exception raised in route, returning 500')
39+
raise e
40+
3541
#######################
3642
## Start Application ##
3743
#######################

0 commit comments

Comments
 (0)