【发布时间】:2021-10-20 00:20:07
【问题描述】:
我正在使用 Quarkus 框架和 RestEasy 进行 REST 通信。 当响应代码为 200 等时,一切正常。当客户端收到错误代码时,例如400 Bad Request resteasy 返回 WebApplicationException,我无法访问响应正文。
MyService.java
@Path("/")
@RegisterRestClient
@RegisterProvider(value = ClientLoggingFilter.class, priority = 100)
public interface MyService {
@POST
@Path("/foo")
@Consumes(MediaType.APPLICATION_JSON)
MyRespnse create(MyRequest request);
我一直在尝试从 WebApplicationException 读取实体,但实体始终为空。在 Postman 服务中,返回正文如下:
{
"error" : {
"id" : "id does not exist"
}
}
【问题讨论】: