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

fix(bft/rpc): check http status code #350

Merged
merged 1 commit into from
Oct 8, 2022

Conversation

tbruyelle
Copy link
Contributor

This change improves the error handling of rpc clients.

Previously, the client tried to unmarshal the response body whatever the returned status code. This typically outputs errors like invalid character '<' looking for beginning of value because the body format is HTML and not JSON. This kind of error is difficult to interpret for the end user, this was mentioned for instance in this issue #329 (comment).

Now, if the status code is not between 200 and 299, the client doesn't try to unmarshal the response body and directly returns an error server at '<ADDRESS>' returned <ERROR_STATUS>.

This change improves the error handling of rpc clients.

Previously, the client tried to unmarshal the response body whatever the
returned status code. This typically outputs errors like `invalid character '<'
looking for beginning of value` because the body format is HTML and not
JSON, and this kind of error is difficult to interpret for the end user.

Now, if the status code is not between 200 and 299, the client doesn't
try to unmarshal the response body and directly returns an error `server at
'<ADDRESS>' returned <ERROR_STATUS>`.
@moul moul merged commit df21894 into gnolang:master Oct 8, 2022
@moul moul added this to the 🏗3️⃣ test3.gno.land milestone Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants