mirror of
https://github.com/kemko/nomad.git
synced 2026-01-05 09:55:44 +03:00
Merge pull request #14145 from hashicorp/cleanup-trim-error-output
api: trim space of error response output
This commit is contained in:
3
.changelog/14145.txt
Normal file
3
.changelog/14145.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:bug
|
||||
api: cleanup whitespace from failed api response body
|
||||
```
|
||||
@@ -143,7 +143,7 @@ deps: ## Install build and development dependencies
|
||||
lint-deps: ## Install linter dependencies
|
||||
## Keep versions in sync with tools/go.mod (see https://github.com/golang/go/issues/30515)
|
||||
@echo "==> Updating linter dependencies..."
|
||||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.46.2
|
||||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.48.0
|
||||
go install github.com/client9/misspell/cmd/misspell@v0.3.4
|
||||
go install github.com/hashicorp/go-hclog/hclogvet@v0.1.4
|
||||
|
||||
|
||||
@@ -1098,9 +1098,10 @@ func requireOK(d time.Duration, resp *http.Response, e error) (time.Duration, *h
|
||||
}
|
||||
if resp.StatusCode != 200 {
|
||||
var buf bytes.Buffer
|
||||
io.Copy(&buf, resp.Body)
|
||||
resp.Body.Close()
|
||||
return d, nil, fmt.Errorf("Unexpected response code: %d (%s)", resp.StatusCode, buf.Bytes())
|
||||
_, _ = io.Copy(&buf, resp.Body)
|
||||
_ = resp.Body.Close()
|
||||
body := strings.TrimSpace(buf.String())
|
||||
return d, nil, fmt.Errorf("Unexpected response code: %d (%s)", resp.StatusCode, body)
|
||||
}
|
||||
return d, resp, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user