Feignclient extracts exception information

  springboot, springcloud

Using feign.codec.ErrorDecoder

@Configuration
public class MyErrorDecoder implements feign.codec.ErrorDecoder {

        @Override
        public Exception decode(String methodKey, Response response) {
            if (response.status() == 404) {
                return new NotFoundException(
                        response.status(),
                        response.reason()
                );
            }
            return errorStatus(methodKey, response);
        }
    }

Extract cause Error Information

HystrixRuntimeException.getCause()
Instance of FeignException, if there is no custom errorDecoder;
If an exception is customized, it is similar to instance of NotFoundException.