diff --git a/README.md b/README.md index d71e2d0..0c1eaae 100644 --- a/README.md +++ b/README.md @@ -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`. diff --git a/web.py b/web.py index 6d9e48f..e3de7db 100644 --- a/web.py +++ b/web.py @@ -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 ## #######################