【发布时间】:2019-11-07 09:19:46
【问题描述】:
在我的应用中,服务 A 与服务 B 通信。 在服务 B 中,我做了一些 db 查询,因此可能会出现 NOT_FOUND 状态。
代码:
服务A
try{
RestTemplate.exchange()...
}catch(HttpStatusCodeException e){
return new ResonseEntity<String>(// Here custom message of service B extracted from e //,e.getStatusCode)
}
服务 B:
return new ResponseEntity<String> ("My Error Message", HttpStatus.NOT_FOUND)
所以基本上我想在服务 A 的异常处理中使用“我的错误消息”。有没有办法将它传递给异常?
【问题讨论】:
标签: java spring rest exception resttemplate