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 27, 2023
1 parent b233a7c commit f2e2ae0
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 @@ -32,6 +32,12 @@
except Exception:
helpers.logger.exception('Exception raised when importing app code')

if os.environ.get('LOG_EXCEPTIONS'):
@app.errorhandler(Exception)
def handle_exception(e):
helpers.logger.exception('Unhandled exception raised in route, returning 500')
raise e

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

0 comments on commit f2e2ae0

Please sign in to comment.