From 8a1fb9a26e087e0ec59384efbe3cbb972a7e8660 Mon Sep 17 00:00:00 2001 From: Nate Sales Date: Mon, 27 Jan 2025 18:49:29 -0500 Subject: [PATCH] fix(fetch): return http error --- pkg/util/fetch_other.go | 4 ++++ pkg/util/fetch_wasm.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/pkg/util/fetch_other.go b/pkg/util/fetch_other.go index 77c50c1..0d8a699 100644 --- a/pkg/util/fetch_other.go +++ b/pkg/util/fetch_other.go @@ -4,6 +4,7 @@ package util import ( + "fmt" "io" "net/http" ) @@ -13,5 +14,8 @@ func get(url string) ([]byte, error) { if err != nil { return nil, err } + if resp.StatusCode > 299 { + return nil, fmt.Errorf("HTTP GET %s: %s", url, resp.Status) + } return io.ReadAll(resp.Body) } diff --git a/pkg/util/fetch_wasm.go b/pkg/util/fetch_wasm.go index 0394371..6f3ae8e 100644 --- a/pkg/util/fetch_wasm.go +++ b/pkg/util/fetch_wasm.go @@ -17,5 +17,8 @@ func get(url string) ([]byte, error) { if err != nil { return nil, err } + if resp.Status > 299 { + return nil, fmt.Errorf("HTTP GET %s: %s", url, resp.Status) + } return resp.Body, nil }