google / webrisk

Apache License 2.0
67 stars 34 forks source link

doRequest does not provide enough information when the response is not a 200 #30

Open digitalfiz opened 1 year ago

digitalfiz commented 1 year ago

Google provides a reason why for some requests when they come back so it would be helpful to provide that response when debugging issues.

We have an issue right now that we can't figure out where after a few days weeks of our app running we start getting 403s from the api but all we get is

webrisk: 2023/01/11 21:01:51 database.go:218: ListUpdate failure (3882620): webrisk: unexpected server response code: 403

Which is not really useful at all and I've tracking it down to line 96 in api.go.

Maybe the return error could contain the body as a string or something until a more developed response error can be created?

I figure this isn't handled yet because the documentation doesn't provide a definition of the possible response bodies when it's not a 200 so without just breaking random parts of the request to see what the responses are it's impossible to know what some type of ErrorResponse would look like.