Created
March 30, 2020 19:49
-
-
Save Porter97/c27ac633e337036dd0412947d44353f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import jsonify | |
from . import main | |
@main.app_errorhandler(403) | |
def forbidden(e): | |
response = jsonify({'errors': {'Forbidden:': [e]}}) | |
response.status_code = 403 | |
return response | |
@main.app_errorhandler(404) | |
def page_not_found(e): | |
response = jsonify({'errors': {'Page Not Found': [e]}}) | |
response.status_code = 404 | |
return response | |
@main.app_errorhandler(500) | |
def internal_server_error(e): | |
response = jsonify({'errors': {'Internal Server Error': [e]}}) | |
response.status_code = 500 | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment