Search code examples
javaexceptionerror-handlingspring-webfluxproject-reactor

How to catch a Reactor RetryExhaustedException?


I have code throwing a reactor.core.Exceptions$RetryExhaustedException and I would like to catch that specific exception.

However, this RetryExhaustedException is not a public class, it is a package-private static class on the public reactor.core.Exceptions-class, so I cannot just put it in a catch-statement. Since the exception extends IllegalStateException I could catch that, but that is a very broad exception that I would prefer not to generally handle.

(Note that I am not talking about the deprecated (public) class reactor.retry.RetryExhaustedException. That is not the same exception.)


Solution

  • I think you could use util method Exceptions.isRetryExhausted(e) to check whether the given exception is RetryExhausted.

    Also with that class you may check others exceptions from Exceptions class, see methods that start with is...