In my app Service A communicates with service B. in Service B I do some db queries so there can come up a NOT_FOUND status.
Code:
Service A
try{
RestTemplate.exchange()...
}catch(HttpStatusCodeException e){
return new ResonseEntity<String>(// Here custom message of service B extracted from e //,e.getStatusCode)
}
Service B:
return new ResponseEntity<String> ("My Error Message", HttpStatus.NOT_FOUND)
So basically I want to use "My Error Message" in the exceptionhandling in Service A. Is there a way to pass it to the exception?