nopaque/app/errors/handlers.py
2022-09-02 13:07:30 +02:00

12 lines
404 B
Python

from flask import render_template, request
from werkzeug.exceptions import HTTPException
from . import bp
@bp.errorhandler(HTTPException)
def generic_error_handler(e):
if (request.accept_mimetypes.accept_json
and not request.accept_mimetypes.accept_html):
return {'errors': {'message': e.description}}, e.code
return render_template('errors/error.html.j2', error=e), e.code