Skip to content

Add orElse callbacks and RetryExhaustedException when retries is exhausted.#184

Closed
drown0315 wants to merge 1 commit into
google:masterfrom
drown0315:feat-orElse
Closed

Add orElse callbacks and RetryExhaustedException when retries is exhausted.#184
drown0315 wants to merge 1 commit into
google:masterfrom
drown0315:feat-orElse

Conversation

@drown0315

Copy link
Copy Markdown

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

@jonasfj jonasfj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread retry/lib/retry.dart
).retry(fn, retryIf: retryIf, onRetry: onRetry);
).retry(fn, retryIf: retryIf, onRetry: onRetry, orElse: orElse);

/// throw [RetryExhaustedException] when retries is exhausted.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitalize

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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😅.

Comment thread retry/lib/retry.dart
/// 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitalize

@drown0315 drown0315 closed this Sep 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants