wakedeer
wakedeer

Reputation: 642

How to handle com.netflix.client.ClientException in Spring Cloud

I have two services: A and B. B makes a request via feign client when starts. But when A is unavailable I get com.netflix.client.ClientException

Caused by: com.netflix.client.ClientException: Load balancer does not have available server for client: A

I'm looking for the best practice for handling such an exception

Upvotes: 0

Views: 1020

Answers (1)

Kirit Patel
Kirit Patel

Reputation: 11

right now there is no official way to catch FeignClient exception. but you can handle FeignClient exception by catching as a java.lang.Exception and throw your own exception.

for ex:

try{
   feignClient.feignMethod();
} catch(Exception ex){
  //throw your own exception
  throw new CustomFeignException();
}

Upvotes: 1

Related Questions