Error decoder doesn't work.
I have 2 microservices M1 M2. M1 use feign client with custom ErrorDecoder for communicating with M2. Then i added Hystrix for circuit breaking if M2 is unavailable.
Feign client:
@FeignClient(name = "M2", fallback = M2Client.Fallback.class)
public interface M2Client{
@GetMapping("/api/v1/users/{id}")
UserDTO getUserById(@PathVariable long id);
//other endpoints
@Component
class Fallback implements M2Client{
@Override
public UserDTO getUserById(long id) {
throw new MicroserviceException("Service is unavailable");
}
}
Error decoder:
@Component
public class CustomErrorDecoder implements ErrorDecoder {
@Override
public Exception decode(String s, Response response) {
//...
}
}
But Custom ErrorDecoder stop working and all time M2 throw error, that calling fallback
Okay, as I understand there is a following way how handling works:
So i changed fallback to fallback factory and just throw exception farther in Fallback class.