Skip to content

Commit

Permalink
More succinct HTTPError messages
Browse files Browse the repository at this point in the history
Before:
`HTTP error, status Code [503], wrapped error is: unexpected response`

After:
`HTTP error, status Code [503] (unexpected response)`

Signed-off-by: Andrew Seigner <siggy@buoyant.io>
  • Loading branch information
siggy committed Aug 8, 2019
1 parent db381a0 commit b09ec86
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/protohttp/protohttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type FlushableResponseWriter interface {

// Error satisfies the error interface for HTTPError.
func (e HTTPError) Error() string {
return fmt.Sprintf("HTTP error, status Code [%d], wrapped error is: %v", e.Code, e.WrappedError)
return fmt.Sprintf("HTTP error, status Code [%d] (%v)", e.Code, e.WrappedError)
}

// HTTPRequestToProto converts an HTTP Request to a protobuf request.
Expand Down
2 changes: 1 addition & 1 deletion pkg/protohttp/protohttp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ func TestCheckIfResponseHasError(t *testing.T) {
t.Fatalf("Expecting error, got nothing")
}

expectedErrorMessage := "HTTP error, status Code [503], wrapped error is: unexpected API response"
expectedErrorMessage := "HTTP error, status Code [503] (unexpected API response)"
actualErrorMessage := err.Error()
if actualErrorMessage != expectedErrorMessage {
t.Fatalf("Expected error message to be [%s], but it was [%s]", expectedErrorMessage, actualErrorMessage)
Expand Down

0 comments on commit b09ec86

Please sign in to comment.