From 701240eb7c162e66af38ad84ac29160126c86c48 Mon Sep 17 00:00:00 2001 From: Antoni Sawicki Date: Tue, 2 Jul 2024 02:54:33 -0700 Subject: [PATCH] process http status code --- txt.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/txt.go b/txt.go index 020d2ac..ae9e52e 100644 --- a/txt.go +++ b/txt.go @@ -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 {