Err returns the reason for terminating the backoff, or nil if it didn't terminate.
()
| 56 | |
| 57 | // Err returns the reason for terminating the backoff, or nil if it didn't terminate. |
| 58 | func (b *Backoff) Err() error { |
| 59 | if b.ctx.Err() != nil { |
| 60 | return b.ctx.Err() |
| 61 | } |
| 62 | if b.cfg.MaxRetries != 0 && b.numRetries >= b.cfg.MaxRetries { |
| 63 | return fmt.Errorf("terminated after %d retries", b.numRetries) |
| 64 | } |
| 65 | return nil |
| 66 | } |
| 67 | |
| 68 | // ErrCause is like Err() but returns the context cause if backoff is terminated because the |
| 69 | // context has been canceled. |