Skip to content

Errorhandler can not respond the correct format data that i want #103

Open
@boh5

Description

@boh5

I want to handle the MothodNotAllowed Exception by that code:

@api.errorhandler(MethodNotAllowed)
    def method_not_allowed(e):
        resp = err_resp('该请求方法不允许', 405, 'The method is not allowed for the requested URL.', {})
        return resp

The err_resp() return that:

{
    "succeed": false,
    "msg": "该请求方法不允许",
    "code": 405,
    "extra": "The method is not allowed for the requested URL.",
    "errors": {},
}

But actually I get that response:

{
    "succeed": false,
    "msg": "该请求方法不允许",
    "code": 405,
    "extra": "The method is not allowed for the requested URL.",
    "errors": {},
    "message": "405 Method Not Allowed: The method is not allowed for the requested URL."
}

The api.errorhandler derector automatically add message field to my response, but I don't need that.
Is there a way to return a plain response without message field when handle exception?
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds_infoRequires more information before more work can be done

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions