Skip to content
New issue

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

Add support for handling final exception #136

Open
johanhaleby opened this issue May 24, 2023 · 0 comments
Open

Add support for handling final exception #136

johanhaleby opened this issue May 24, 2023 · 0 comments

Comments

@johanhaleby
Copy link
Owner

Currently, you can do:

RetryStrategy
                .exponentialBackoff(Duration.ofSeconds(1), Duration.ofSeconds(5), 2.0)
                .maxAttempts(10)
                .onError { info, throwable -> println("somethign") }
                .execute(..)

But it would be nice to do something on "completion with failure", for example, to avoid avoid try/catch around the retry strategy. E.g.

RetryStrategy
                .exponentialBackoff(Duration.ofSeconds(1), Duration.ofSeconds(5), 2.0)
                .maxAttempts(10)
                .onError { info, throwable -> println("somethign") }
                .execute(..)
                .mapError(throwable -> // return a new throwable )

and/or:

RetryStrategy
                .exponentialBackoff(Duration.ofSeconds(1), Duration.ofSeconds(5), 2.0)
                .maxAttempts(10)
                .onError { info, throwable -> println("somethign") }
                .execute(..)
                .onCompletedWithError(throwable -> ) // Maybe add "onCompletedSuccessfully" or replace with common "onCompleted" method?

and/or:

RetryStrategy
                .exponentialBackoff(Duration.ofSeconds(1), Duration.ofSeconds(5), 2.0)
                .maxAttempts(10)
                .onError { info, throwable -> println("somethign") }
                .execute(..)
                .returnIfCompletedWithError(throwable -> "something else" ) // Move back to happy track (Better name needed)

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

No branches or pull requests

1 participant