diff --git a/pkg/uhttp/wrapper.go b/pkg/uhttp/wrapper.go index 0aa26069..1302ba14 100644 --- a/pkg/uhttp/wrapper.go +++ b/pkg/uhttp/wrapper.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "encoding/json" + "fmt" "io" "net/http" "net/url" @@ -49,6 +50,10 @@ func (c *BaseHttpClient) Do(req *http.Request, options ...DoOption) (*http.Respo } } + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + return resp, fmt.Errorf("unexpected status code: %d", resp.StatusCode) + } + return resp, err }