Open shivasantosh opened 4 years ago
I'm bothering with this problem too. In fact, throwing a custom exception sometime reduce complexity, think of a @service invoke a FeignClient's interface which returns a DTO, when interface curcuit break then go to fallback method then throws a custom exception, IF this custom exception is NOT turn into HystrixRunTimeException , then @ExceptionHandler will handle this custom exception(this exception contains msg provided where it throws). But in fact a custom exception is totally turn into HystrixRunTimeException without any "cause" exception info that can be found--this is not so reasonable I think.
yeah @ZengRed I guess this should be to feign core may be. I'll try to paste the same info there
Solution is quite easy - just extend your exception from HystrixBadRequestException
, details here https://netflix.github.io/Hystrix/javadoc/com/netflix/hystrix/exception/HystrixBadRequestException.html
it's not working we have checked even extending. It works with plain Hystrix But we need fall back mechanism for feign where feign internally uses Hystrix. @cmyker
Works for me, in similar manner described here https://stackoverflow.com/a/58414584/1079659
Let me explain it clearly. @cmyker
In the above image the application is throwing HystrixRuntimeException where we should unwrap it.
But I donot want it to be wrapped because as soon as I throw ProductNotFoundException. In business logic it should catch with ProductNotFoundException. But in the hystrix case we should catch with HystrixRuntimeException I was unable to differentiate exception till I unwrap it.
In my case there is different logics needs to be done for different exceptions. but if it is only HystrixRuntimeException till I unwrap it I cannot differentiate my logic
In the business layer I should not see HystrixRuntimeException. I need ProductNotFoundException directly in catch block
Fallback service is wrapping ProductNotFoundException into HystrixRunTimeException. I want to propagate custom exception as it is instead of wrapping into HystrixRunTimeException. Below is the code snippet for reference:
@FeignClient(name = "service1", fallback = FallBackService1.class ) public interface FeignService1{ String validateProducts(Product product); }
class FallBackService1 implements FeignService1{ @Override public String validateProducts(Product product){ throw new ProductNotFoundException("P119","Product not found"); } }
I have enabled feign.hystrix.enable = true.
Please help with this. I want to propagate the exception as it is. I do not want it to be wrapped.