I have some fiegn client to send request other micro service.
@FeignClient(name="userservice")
public interface UserClient {
@RequestMapping(
method= RequestMethod.GET,
path = "/userlist")
String getUserByid(@RequestParam(value ="id") String id);
}
Now I am sending request like this
try {
String responseData = userClient.getUserByid(id);
return responseData;
}
catch(FeignException e)
{
logger.error("Failed to get user", id);
}
catch (Exception e)
{
logger.error("Failed to get user", id);
}
Here the problem is if any FeignException happens I dont get any error code.
I need to send a corresponding error codes in other APIS to send to caller
So how to extract the error code? I want to extract error code and build a responseEntity
I got this code but dont know how exactly I can use in my function.