process http status code

This commit is contained in:
Antoni Sawicki 2024-07-02 02:54:33 -07:00
parent 1d9af26604
commit 701240eb7c

3
txt.go
View File

@ -94,6 +94,9 @@ func grabImage(id, url string) error {
if err != nil {
return fmt.Errorf("Error downloading %q: %v", url, err)
}
if r.StatusCode != http.StatusOK {
return fmt.Errorf("%q status code: %v", url, r.StatusCode)
}
defer r.Body.Close()
img, err = io.ReadAll(r.Body)
if err != nil {