I am making 2 API calls:
Response result1 = restTemplate.postForObject(api1url, data1, Response.class);
Response result2 = restTemplate.postForObject(api2url, data2, Response.class);
I am using @RestControllerAdvice
to handle the error if any service is down (505 Unavailable)
So an API is down, I will receive 505 regardless which API it is
which I will handle it in @RestControllerAdvice
. But the problem is I don't know which API is down. I can use try-catch to solve this problem but since overall I am making many API calls this would clutter my code and also I want to ( as practically much I can) to use only RestControllerAdvice
to handle all exceptions.
My goal is to use RestControllerAdvice
to handle exceptions specific to each API when it is down
Is there a way? Thanks