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

#330: Handling error with complex object body #333

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MatthewBAllen
Copy link

We received two different error response formats.

one:
{
"error": "Couldn't authenticate you"
}

two:
{
"error": {
"title": "Forbidden",
"message": "You do not have access to this page. Please contact the account owner of this help desk for further help."
}
}

The current ErrorResponse model class was able to handle the first response but would throw this error with the second response: "Unexpected character encountered while parsing value: {. Path 'error', line 2, position 12" because it's expecting a string value for error but instead it hits a complex object . The new ErrorWithMessageResponse model class will allow the user to deserialize the second response and convert it to an ErrorResponse object.

…or with object body

We received two different error message formats.

one:
{
    "error": "Couldn't authenticate you"
}

two:
{
    "error": {
        "title": "Forbidden",
        "message": "You do not have access to this page. Please contact the account owner of this help desk for further help."
    }
}

The current ErrorResponse model class was able to handle the first response but would throw this error with the second response: "Unexpected character encountered while parsing value: {. Path 'error', line 2, position 12" because it's expecting a string value for error but instead it hits a complex object . The new ErrorWithMessageResponse model class will allow the user to deserialize the second response and convert it to an ErrorResponse object.
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

Successfully merging this pull request may close these issues.

1 participant