Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception handling #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
10 changes: 8 additions & 2 deletions web.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@
try:
module_path = 'ext.app.{}'.format(app_file)
import_module(module_path)
except Exception as e:
helpers.log(str(e))
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