Handle http errors
This commit is contained in:
parent
07bd886383
commit
3a29b3b869
@ -77,6 +77,9 @@ func getJson(url string, target interface{}) (err error) {
|
|||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode >= 400 {
|
||||||
|
return fmt.Errorf("%d", resp.StatusCode)
|
||||||
|
}
|
||||||
return json.NewDecoder(resp.Body).Decode(target)
|
return json.NewDecoder(resp.Body).Decode(target)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user