Skip to content

Commit

Permalink
fix-errors
Browse files Browse the repository at this point in the history
Signed-off-by: Yuri Shkuro <github@ysh.us>
  • Loading branch information
yurishkuro committed Jan 25, 2025
1 parent 4f63e86 commit e5dae10
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cmd/query/app/http_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -991,11 +991,11 @@ func postJSON(url string, req any, out any) error {

type HTTPError struct {
StatusCode int
Err error
Body string
}

func (e *HTTPError) Error() string {
return fmt.Sprintf("HTTP Error %d: %v", e.StatusCode, e.Err)
return fmt.Sprintf("%d error from server: %s", e.StatusCode, e.Body)
}

// execJSON executes an http request against a server and parses response as JSON
Expand All @@ -1017,7 +1017,10 @@ func execJSON(req *http.Request, additionalHeaders map[string]string, out any) e
if err != nil {
return err
}
return &HTTPError{StatusCode: resp.StatusCode, Err: errors.New(string(body))}
return &HTTPError{
StatusCode: resp.StatusCode,
Body: string(body),
}
}

if out == nil {
Expand Down

0 comments on commit e5dae10

Please sign in to comment.