Skip to content

Commit

Permalink
chore: add http status description
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Mar 15, 2023
1 parent 720c6b8 commit 4cf901f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions util/request/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ func NewStatusError(resp *http.Response) StatusError {
}

func (e StatusError) Error() string {
return fmt.Sprintf("unexpected status: %d", e.resp.StatusCode)
return fmt.Sprintf("unexpected status: %d (%s)", e.resp.StatusCode, http.StatusText(e.resp.StatusCode))
}

// Response returns the respose with the unexpected error
// Response returns the response with the unexpected error
func (e StatusError) Response() *http.Response {
return e.resp
}

// StatusCode returns the respose's status code
// StatusCode returns the response's status code
func (e StatusError) StatusCode() int {
return e.resp.StatusCode
}

// HasStatus returns true if the respose's status code matches any of the given codes
// HasStatus returns true if the response's status code matches any of the given codes
func (e StatusError) HasStatus(codes ...int) bool {
for _, code := range codes {
if e.resp.StatusCode == code {
Expand Down

0 comments on commit 4cf901f

Please sign in to comment.