Skip to content

Commit aaa6318

Browse files
committed
Add env var to add an exception logging errorhandler
1 parent 59fc614 commit aaa6318

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
@@ -33,6 +33,12 @@
3333
except Exception as e:
3434
helpers.log(''.join(traceback.format_exception(None, e, e.__traceback__)))
3535

36+
if os.environ.get('LOG_EXCEPTIONS'):
37+
@app.errorhandler(Exception)
38+
def handle_exception(e):
39+
helpers.log(''.join(traceback.format_exception(None, e, e.__traceback__)))
40+
raise e
41+
3642
#######################
3743
## Start Application ##
3844
#######################

0 commit comments

Comments
 (0)