Skip to content

Commit

Permalink
fix(fetch): return http error
Browse files Browse the repository at this point in the history
  • Loading branch information
natesales committed Jan 27, 2025
1 parent 3809171 commit 8a1fb9a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/util/fetch_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package util

import (
"fmt"
"io"
"net/http"
)
Expand All @@ -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)
}
3 changes: 3 additions & 0 deletions pkg/util/fetch_wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 8a1fb9a

Please sign in to comment.