Skip to content

Instantly share code, notes, and snippets.

@Porter97
Created March 30, 2020 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Porter97/3221fc64e8401ce5ce0816cd764b5c96 to your computer and use it in GitHub Desktop.
Save Porter97/3221fc64e8401ce5ce0816cd764b5c96 to your computer and use it in GitHub Desktop.
from flask import jsonify
from . import auth
@auth.app_errorhandler(403)
def forbidden(e):
response = jsonify({'errors': {'Forbidden:': [e]}})
response.status_code = 403
return response
@auth.app_errorhandler(404)
def page_not_found(e):
response = jsonify({'errors': {'Page Not Found': [e]}})
response.status_code = 404
return response
@auth.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