I'm using Spring Cloud Circuit Breaker 2.0.0 (resilience4j implementation) for circuit breaking in my application. Let's say a have method define like this:
String doStuff() {
...
// Oh no, something went wrong
throw new SomethingWentWrongException();
...
}
I wrap doStuff in the circuit breaker:
return circuitBreakerFactory.create("doStuff").run(() -> doStuff());
When SomethingWentWrongException is thrown, and I haven't declared a fallback for the circuit breaker, then SomethingWentWrongException will be wrapped in an instance of org.springframework.cloud.client.circuitbreaker.NoFallbackAvailableException as the "cause".
My question is: Is there anyway to configure so that Spring Cloud CircuitBreaker doesn't wrap SomethingWentWrongException in NoFallbackAvailableException and simply just throws the SomethingWentWrongException instead.
you can disable the circuit breaker using this property to throw the original exception:
but then if you have other fallback classes in your feign clients they are going to stop working. I would keep it enabled and just provide a fallback to your feign client and then you can handle this more nicely, or check the cause for a source exception.