Open YishuiLi opened 3 years ago
Ask a question Error handler regiter on one namespace, but actually the error handler was registered on all namespaces.!
Environment
Code
from flask import Blueprint from flask_restx import Api from app.api.useraction import user_ns from app.api.engine import engine_ns api_v1 = Blueprint('api', __name__, url_prefix='/') engine_ns = Namespace('engine', description='Engine Namespace') user_ns = Namespace('user', description='User Namespace') api = Api( api_v1, version='1.0', title='test', description='test', ) api.add_namespace(user_ns) api.add_namespace(engine_ns)
from app.base_api import api from app.api.useraction import user_ns from app.api.engine import engine_ns @api.errorhandler(Exception) def en_handle_exception(error): error_msg = str(error) return {"message": error_msg}, 500 @engine_ns.errorhandler(Exception) def engine_exception(error): error_msg = "engine exception" return {"message": error_msg}, 500 @user_ns.errorhandler(Exception) def user_exception(error): error_msg = "user exception" return {"message": error_msg}, 500
Result When I call the api in the Engine Namespace, the engine error handler was triggered.
But when I call the api in the User Namespace, the engine error handler was also triggered and the user error handler wasn't triggered.
Expected result When I call the api in the Engine Namespace, the engine error handler was triggered.
When I call the api in the User Namespace, the user error handler was triggered.
This happens on version 0.4.0 too. Are there any plans to fix it? Do you guys know where the bug is? Maybe I can fix it
Any news about this issue ?
Ask a question Error handler regiter on one namespace, but actually the error handler was registered on all namespaces.!
Environment
Code
Result When I call the api in the Engine Namespace, the engine error handler was triggered.
But when I call the api in the User Namespace, the engine error handler was also triggered and the user error handler wasn't triggered.
Expected result When I call the api in the Engine Namespace, the engine error handler was triggered.
When I call the api in the User Namespace, the user error handler was triggered.