h2non/gentleman

Silent JSON response decoding failures

kcq opened this issue · 4 comments

kcq commented

response.JSON() doesn't return any errors when there's a failure to decode the response data into the expected structure.

h2non commented

You should manage the error via "error" middleware phase, which would be triggered in case of error. See middleware implementation. I will also create a representative example about this.

kcq commented

What's the purpose of the error return value in the .JSON() method then?

h2non commented

Where did you see that?

h2non commented

You can see an error middleware handling example here:
https://github.com/h2non/gentleman/blob/master/_examples/error-handler/error.go