1
0

Handle http errors

This commit is contained in:
dump_stack() 2023-05-11 12:54:54 +00:00
parent 07bd886383
commit 3a29b3b869
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC

View File

@ -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)
} }