the exceptions module: you can import lot of exceptions from this module that helps you to raise exceptions that will be well formatted according to JSONAPI 1.0 specification
def permission_manager(view, view_args, view_kwargs, *args, **kwargs):
raise JsonApiException('Test', "You don't have the ability to be here")
It raises a 500 error as HTML.
My API init is (bootstrap.py) :
from flask import current_app as app, Blueprint
from flask_rest_jsonapi import Api
from myapp.api.helpers.permission_manager import permission_manager
api_v1 = Blueprint('v1', __name__, url_prefix='/v1')
api = Api(app, api_v1)
api.permission_manager(permission_manager)
My app init is :
app = Flask('myapp')
with app.app_context():
from myapp.api.bootstrap import api_v1
app.register_blueprint(api_v1)