# HG changeset patch # User Mikael Berthe # Date 1492030935 -7200 # Node ID 05c201b548b0a6b2ad50cb95990e4ec0563403d4 # Parent ae9ad3c7bca5b3f288ab9e34c1e479799255a215 Timelines: Handle error from API server diff -r ae9ad3c7bca5 -r 05c201b548b0 timelines.go --- a/timelines.go Wed Apr 12 22:46:16 2017 +0200 +++ b/timelines.go Wed Apr 12 23:02:15 2017 +0200 @@ -30,6 +30,13 @@ err = json.Unmarshal([]byte(r.Body), &tl) if err != nil { + var res struct { + Error string `json:"error"` + } + err2 := json.Unmarshal([]byte(r.Body), &res) + if err2 == nil { + return tl, fmt.Errorf("%s", res.Error) + } return tl, fmt.Errorf("timelines API: %s", err.Error()) }