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 <n3wscott@chainguard.dev>
  • Loading branch information
n3wscott committed Mar 24, 2022
1 parent 0b3b53d commit b060ffb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion v2/protocol/http/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,14 @@ 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 append the original error string.
if og, ok := err.(*Result); ok {
og.Format = og.Format + "%s"
og.Args = append(og.Args, errorStr)
err = og
} else {
err = NewResult(res.StatusCode, "%w: %s", err, errorStr)
}
}
}
}
Expand Down

0 comments on commit b060ffb

Please sign in to comment.