From 63d91faa5092e8025853a77c724823c19c8ae1f2 Mon Sep 17 00:00:00 2001 From: kon3gor Date: Mon, 2 Sep 2024 10:58:00 +0300 Subject: [PATCH] code fixes --- client.go | 10 +++------- util.go | 39 --------------------------------------- 2 files changed, 3 insertions(+), 46 deletions(-) diff --git a/client.go b/client.go index 4afe8153..a3762567 100644 --- a/client.go +++ b/client.go @@ -1236,14 +1236,10 @@ func (c *Client) execute(req *Request) (*Response, error) { if err != nil || req.notParseResponse || c.notParseResponse { logErr := responseLogger(c, response) response.setReceivedAt() - switch { - case err != nil && logErr != nil: - return response, wrapResponseLogErr(err, logErr) - case logErr != nil: - return response, wrapNoRetryErr(logErr) - default: - return response, err + if err != nil { + return response, errors.Join(err, logErr) } + return response, wrapNoRetryErr(logErr) } if !req.isSaveResponse { diff --git a/util.go b/util.go index 90a85365..7bbba912 100644 --- a/util.go +++ b/util.go @@ -382,42 +382,3 @@ func unwrapNoRetryErr(err error) error { } return err } - -// Code to backfill until Resty go minimum version gets updated to go1.20 -// TODO: Replace with errors.Join -type responseLogErr struct { - internalErr error - logErr error -} - -func wrapResponseLogErr(err error, logErr error) error { - if logErr == nil { - return err - } - - if err == nil { - return logErr - } - - return &responseLogErr{ - logErr: logErr, - internalErr: err, - } -} - -func (e *responseLogErr) Wrap(other error) error { - if e == nil { - return other - } - - e.internalErr = other - return e -} - -func (e *responseLogErr) Error() string { - if e.internalErr != nil { - return fmt.Sprintf("got log error along with: %s. Log error was: %s", e.internalErr.Error(), e.logErr.Error()) - } - - return e.logErr.Error() -}