Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error handle with unexpect response #931

Open
sleepingF0x opened this issue Jan 25, 2022 · 0 comments
Open

error handle with unexpect response #931

sleepingF0x opened this issue Jan 25, 2022 · 0 comments

Comments

@sleepingF0x
Copy link

sleepingF0x commented Jan 25, 2022

my error define:

errors = {
    'ValidationError': {
        'message': "param error",
        'status': 400,
    }
}

api = Api(blueprint, catch_all_404s=True, errors=errors)

my marshmallow.schema

class Schema(ma.SQLAlchemyAutoSchema):
    url = ma.String(required=True, validate=[validate.Length(min=8, max=200)])
    key = ma.String(required=True, validate=[validate.Length(min=2, max=32)])
def post(self):
      mySchema.load(request.json)

post data, and expect with the following errors(key min=2, max=32 ), but seems did not work..

[
        {"url": "someurl",  "key": ""}
]

errors expect to be:

{
    "data": [
        {
            "url": "someurl",
            "key": "",
        }
    ],
    "message": "param error",
    "status": 400
}

after I review the code, I add some code to deal with kind of issues..and hope to help those who encounter such problems like me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant