From c47eac24b994daaa5ddddc80fb96e392f3d91671 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Thu, 8 Oct 2015 20:30:55 +0200 Subject: Report error --- weather.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/weather.go b/weather.go index 768ab93..7cee4b4 100644 --- a/weather.go +++ b/weather.go @@ -3,6 +3,7 @@ package weather import ( "encoding/json" + "errors" "fmt" "io/ioutil" "net/http" @@ -158,6 +159,9 @@ func get(param string) (Current, error) { return c, err } defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + return Current{}, errors.New(resp.Status) + } body, err := ioutil.ReadAll(resp.Body) if err != nil { return c, err -- cgit v1.2.3