How can we catch two different exceptions (ex. from .lang and .io packages) in the same block of @Retryable method. One, we return an IOException and the other we retry the method.
@Retryable(value = {Exception.calss } ,maxAttempts = 3, backoff = @Backoff(delay = 3000))
public String getInfo() {
try {
//here we have an executive code that may have an IOException
} catch(Exception ex) {
//And here i would catch the Exception
throw new Exception();
}
}
You can use the include parameter of the annotation to handle multiple various exceptions:
@Retryable(
include = { IllegalAccessException.class, IOException.class },
maxAttempts = 3,
backoff = @Backoff(delay = 3000))
public String getInfo() {
// some code
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With