From 45ace4b352928971318ca82c7282aa8366e2b36e Mon Sep 17 00:00:00 2001 From: roc Date: Thu, 22 Jun 2023 23:42:17 +0800 Subject: [PATCH] ensure err in client.roundTrip --- client.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 96793361..f95fe32f 100644 --- a/client.go +++ b/client.go @@ -1509,7 +1509,11 @@ func (c *Client) WrapRoundTrip(wrappers ...RoundTripWrapper) *Client { func (c *Client) roundTrip(r *Request) (resp *Response, err error) { resp = &Response{Request: r} defer func() { - err = resp.Err + if err != nil { + resp.Err = err + } else { + err = resp.Err + } }() if r.Headers == nil {