1
0
Fork 0

Handle http errors

master
dump_stack() 2023-05-11 12:54:54 +00:00
parent 07bd886383
commit 3a29b3b869
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC
1 changed files with 3 additions and 0 deletions

View File

@ -77,6 +77,9 @@ func getJson(url string, target interface{}) (err error) {
}
defer resp.Body.Close()
if resp.StatusCode >= 400 {
return fmt.Errorf("%d", resp.StatusCode)
}
return json.NewDecoder(resp.Body).Decode(target)
}