Skip to content

Commit

Permalink
Add env var to add an exception logging errorhandler
Browse files Browse the repository at this point in the history
  • Loading branch information
piemonkey committed Sep 22, 2023
1 parent 59fc614 commit aaa6318
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ my-python:

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

- `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.

- `MU_SPARQL_ENDPOINT` is used to configure the SPARQL endpoint.

- 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`.
Expand Down
6 changes: 6 additions & 0 deletions web.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
except Exception as e:
helpers.log(''.join(traceback.format_exception(None, e, e.__traceback__)))

if os.environ.get('LOG_EXCEPTIONS'):
@app.errorhandler(Exception)
def handle_exception(e):
helpers.log(''.join(traceback.format_exception(None, e, e.__traceback__)))
raise e

#######################
## Start Application ##
#######################
Expand Down

0 comments on commit aaa6318

Please sign in to comment.