Skip to content

Commit

Permalink
fix: include status error
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-bisonai committed Feb 23, 2024
1 parent 32698f0 commit ee2315b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions node/pkg/utils/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package utils
import (
"bytes"
"encoding/json"
"errors"
"io"
"net/http"
"net/url"
Expand Down Expand Up @@ -68,6 +69,15 @@ func UrlRequest[T any](urlEndpoint string, method string, requestBody interface{
log.Info().Err(err).Msg("failed to make request")
return result, err
}

if response.StatusCode != http.StatusOK {
log.Info().
Int("status", response.StatusCode).
Str("url", urlEndpoint).
Msg("failed to make request")
return result, errors.New("failed to make request")
}

resultBody, err := io.ReadAll(response.Body)
if err != nil {
log.Info().Err(err).Msg("failed to read response body")
Expand Down

0 comments on commit ee2315b

Please sign in to comment.