我使用Reactor-netty执行一个发布请求 代码是这个
(req, resp) -> resp.addHeader(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.APPLICATION_JSON)
.status(HttpResponseStatus.OK)
.sendString(req
.receive()
.map(byteBuf -> {
CommonResponse<Object> response;
try {
response = (CommonResponse<Object>) method.invoke(handleObject, getMethodParams(method, req, resp, byteBuf));
} catch (Exception e) {
response = exceptionPublisher(e);
// in here i need get the code to change response status
int errorCode = response.getErr_code();
...?
}
return response;
})
.map(gsonCreate::toJson)
);
但是,execute方法可能会引发自定义错误
并且我需要这种观念s error code to chanage the response status , now I can
不要这样做,该怎么办?谢谢