Skip to content

Exercise 33 Code Issues #13

Description

@rolimatrix

In Class \Ressources\User.py you wrote this Code:
class UserListResource(Resource):
def post(self):

    json_data = request.get_json()
    data, errors = user_schema.load(data=json_data)

But data, errors = user_schema.load(data=json_data) will ever issue execptions.

I changed with: from marshmallow import ValidationError
to:
try:
data = user_schema.load(data=json_data)
except ValidationError as errors:
return {'message': 'Validation errors', 'errors': errors.messages}, HTTPStatus.BAD_REQUEST

Now its working very well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions