More succinct HTTPError messages (#3221)

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>
This commit is contained in:
Andrew Seigner 2019-08-08 17:39:36 -07:00 committed by GitHub
parent 0267f01641
commit 0487688bc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -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.

View File

@ -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)