briandowns / openweathermap

Go (golang) package for use with openweathermap.org's API.
Apache License 2.0
240 stars 70 forks source link

Failed but succesfull HTTP calls hard to debug #111

Open kvij opened 4 months ago

kvij commented 4 months ago

When the HTTP call itself succeeds there is no error given while the action does fail. This happens when there is a non 2xx status code like when an invalid API KEY is provided or there is a subscription issue. Normally this can be checked in the response but this library handles responses without returning them.

So even if the status code indicates a failure the response of the library is a normal result without an error. The result struct will contain the default zero values of the type. The only way to debug this is by actually using a debugger to inspect the values.

I think that the status code should be checked for non 2xx status codes and an error with the status code and perhaps even the body should be returned.