【发布时间】:2019-10-10 17:12:54
【问题描述】:
假设我用 RestTemplate 调用一个 web 服务,它返回 500 状态错误这个正文:
{
"timestamp": "2019-10-10T16:51:15Z",
"status": 500,
"error": "Internal Server Error",
"message": "Error occurred while retrieving entity with id: bb00b45c-9e17-4d75-a89a",
"path": "/api/service"
}
目前 RestTemplate 异常消息是这样的:
Caused by: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 null
at org.springframework.web.client.HttpServerErrorException.create(HttpServerErrorException.java:79)
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:124)
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:102)
有什么方法可以在不使用自定义错误处理程序的情况下将响应正文包含在 RestTemplate 异常消息中?
谢谢!
【问题讨论】:
标签: spring resttemplate