Skip to content

Commit

Permalink
code fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kon3gor committed Sep 2, 2024
1 parent 1494fe0 commit 63d91fa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 46 deletions.
10 changes: 3 additions & 7 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
39 changes: 0 additions & 39 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

0 comments on commit 63d91fa

Please sign in to comment.