Skip to content

Commit

Permalink
special case http errors if the first error is not wrapped
Browse files Browse the repository at this point in the history
Signed-off-by: Scott Nichols <[email protected]>
  • Loading branch information
n3wscott committed Mar 24, 2022
1 parent 0b3b53d commit a43e5cb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion v2/protocol/http/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,12 @@ func (p *Protocol) Send(ctx context.Context, m binding.Message, transformers ...
buf := new(bytes.Buffer)
buf.ReadFrom(message.BodyReader)
errorStr := buf.String()
err = NewResult(res.StatusCode, "%w: %s", err, errorStr)
// If the error is not wrapped, then just add the message body.
if _, ok := err.(*Result); ok {
err = NewResult(res.StatusCode, "%s", errorStr)
} else {
err = NewResult(res.StatusCode, "%w: %s", err, errorStr)
}
}
}
}
Expand Down

0 comments on commit a43e5cb

Please sign in to comment.