We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In retry func, if I have error, i return errors.Wrapf(someErr, "someWrap text", some wrap values). And retry func return me this type for error:
errors.Wrapf(someErr, "someWrap text", some wrap values)
But I need extract someErr, from returned error. Usually I do this by this code:
someErr
for errors.Unwrap(err) != nil { err = errors.Unwrap(err) }
But with retry this method doesn't work.
Full code:
err = retry.Do( func() error { defer func() { sentCount++ }() responseBody, statusCode, err = h.Request(ctx, args.RequestParams) if err != nil { return errors.Wrapf(err, "fhttp.RequestWithRetry(args: %s)", utils.GetStructJSON(args)) // if last retry this need to unwrap err } if statusCode != args.ExpectedStatusCode { if statusCode == fasthttp.StatusUnauthorized { return ErrStatusUnauthorized } return errors.Wrapf( ErrNotExpectedStatusCode, "fhttp.RequestWithRetry, expeced %d, got %d statusCode; requestArgs: %s, responseBody: %s", args.ExpectedStatusCode, statusCode, utils.GetStructJSON(args), responseBody, ) // if last retry in this part of code need possibility unwrap to ErrNotExpectedStatusCode } return nil }, retry.Delay(args.RetryDelay*time.Millisecond), retry.RetryIf(func(err error) bool { if ((errors.Is(err, fasthttp.ErrTimeout) || errors.Is(err, fasthttp.ErrDialTimeout) || errors.Is(err, fasthttp.ErrTLSHandshakeTimeout)) && sentCount >= 2) || errors.Is(err, ErrStatusUnauthorized) { return false } return true }), retry.Attempts(args.RetryAttempts), ) for errors.Unwrap(err) != nil { // do nothing err = errors.Unwrap(err) }
The text was updated successfully, but these errors were encountered:
feat: unwrap error support (issue #65)
6a4fa52
it should be solved by #70
Sorry, something went wrong.
Merge pull request #70 from avast/unwrap_error_support
2389640
solved in version 4.2.0
Unwrap() []error
No branches or pull requests
In retry func, if I have error, i return
errors.Wrapf(someErr, "someWrap text", some wrap values)
.And retry func return me this type for error:
But I need extract
someErr
, from returned error.Usually I do this by this code:
But with retry this method doesn't work.
Full code:
The text was updated successfully, but these errors were encountered: