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

MultiJson::ParseError is thrown on HTTP error 5XX #226

Closed
utay opened this issue Aug 9, 2023 · 1 comment · Fixed by #250
Closed

MultiJson::ParseError is thrown on HTTP error 5XX #226

utay opened this issue Aug 9, 2023 · 1 comment · Fixed by #250

Comments

@utay
Copy link

utay commented Aug 9, 2023

Context

In case of HTTP errors 5XX, HTML can be returned - for example <head><title>api.mangopay.com | 520: Web server is returning an unknown error</title> ... or <head><title>502 Bad Gateway</title> ....

Current behavior

In this case the SDK throws MultiJson::ParseError because it tries to decode the response body before checking the status code. We could rescue the parse error and retry but it feels unsafe in case there are valid requests that return a non-JSON body.

Expected behavior

Ideally we can rescue MangoPay::ResponseError and depending on the status code we decide whether we retry the request or not.

@rfkdali
Copy link

rfkdali commented Feb 5, 2024

Same issue

@iulian03 iulian03 linked a pull request Apr 10, 2024 that will close this issue
iulian03 added a commit that referenced this issue Apr 10, 2024
…rror-handling

improved error handling and updated tests
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 a pull request may close this issue.

2 participants