Skip to content

Commit

Permalink
Merge pull request #744 from alphagov/add-default-exception-handler
Browse files Browse the repository at this point in the history
Add application level error handler.
  • Loading branch information
servingUpAces committed Nov 25, 2016
2 parents 2e15786 + 52c8596 commit 669126d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ def after_request(response):
response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE')
return response

@app.errorhandler(Exception)
def exception(error):
app.logger.exception(error)
# error.code is set for our exception types.
return jsonify(result='error', message=error.message), error.code or 500

@app.errorhandler(404)
def page_not_found(e):
msg = e.description or "Not found"
Expand Down

0 comments on commit 669126d

Please sign in to comment.