Add orElse callbacks and RetryExhaustedException when retries is exhausted.#184
Add orElse callbacks and RetryExhaustedException when retries is exhausted.#184drown0315 wants to merge 1 commit into
Conversation
jonasfj
left a comment
There was a problem hiding this comment.
This is a breaking change, even if orElse is omitted.
Is it really better to get a retries exhausted exception, rather than throwing the last exception that was caught?
We'd need to investigate of breaking this package would affect many users.
| ).retry(fn, retryIf: retryIf, onRetry: onRetry); | ||
| ).retry(fn, retryIf: retryIf, onRetry: onRetry, orElse: orElse); | ||
|
|
||
| /// throw [RetryExhaustedException] when retries is exhausted. |
There was a problem hiding this comment.
This is a breaking change, even if
orElseis omitted.Is it really better to get a retries exhausted exception, rather than throwing the last exception that was caught?
We'd need to investigate of breaking this package would affect many users.
I think the reason you need RetryExhaustException is that when you need to do subsequent processing for a retry failure, you need to repeatedly use the logic in retryIf to determine if the exception is a failed retry.
Maybe not needing RetryExhaustException, orElse to handle only the retryIf exceptions is a better way?
But here the RetryExhaustException throwing should rely on retryIf, a little embarrassing😅.
| /// thrown. To retry on an [Error], the error must be caught and _rethrown_ | ||
| /// as an [Exception]. | ||
| /// | ||
| /// if retries is exhausted, the result of invoking the [orElse] function is returned. |
if retries is exhausted, the result of invoking the [orElse] function is returned.
If [orElse] is omitted, it defaults to throwing a [RetryExhaustedException]
when retries is exhausted.
reference by issues #167