The Response Filter and Response Interceptor handle exceptions (#12722)
Signed-off-by: crazyhzm <crazyhzm@gmail.com>
This commit is contained in:
parent
1c5265073b
commit
65491fda07
|
|
@ -121,16 +121,14 @@ public class ServiceInvokeRestFilter implements RestRequestFilter {
|
|||
+ "\n message is: " + result.getException().getMessage()
|
||||
+ "\n stacktrace is: " + stackTraceToString(exception));
|
||||
}
|
||||
} else {
|
||||
|
||||
try {
|
||||
// invoke the intercept chain before Result write to response
|
||||
executeResponseIntercepts(url, request, nettyHttpResponse, result.getValue(), rpcInvocation, serviceDeployer);
|
||||
} catch (Exception exception) {
|
||||
logger.error("", exception.getMessage(), "", "dubbo rest protocol execute ResponseIntercepts error", exception);
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// invoke the intercept chain before Result write to response
|
||||
executeResponseIntercepts(url, request, nettyHttpResponse, result.getValue(), rpcInvocation, serviceDeployer);
|
||||
} catch (Exception exception) {
|
||||
logger.error("", exception.getMessage(), "", "dubbo rest protocol execute ResponseIntercepts error", exception);
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,8 +85,6 @@ public class NettyHttpHandler implements HttpHandler<NettyRequestFacade, NettyHt
|
|||
// first request filter
|
||||
executeFilters(url, requestFacade, nettyHttpResponse, serviceDeployer, restRequestFilters);
|
||||
|
||||
// second response filter
|
||||
executeFilters(url, requestFacade, nettyHttpResponse, serviceDeployer, restResponseFilters);
|
||||
} catch (PathNoFoundException pathNoFoundException) {
|
||||
logger.error("", pathNoFoundException.getMessage(), "", "dubbo rest protocol provider path no found ,raw request is :" + nettyHttpRequest, pathNoFoundException);
|
||||
nettyHttpResponse.sendError(404, pathNoFoundException.getMessage());
|
||||
|
|
@ -102,6 +100,14 @@ public class NettyHttpHandler implements HttpHandler<NettyRequestFacade, NettyHt
|
|||
+ " , stacktrace is: " + ServiceInvokeRestFilter.stackTraceToString(throwable));
|
||||
}
|
||||
|
||||
// second response filter
|
||||
try {
|
||||
executeFilters(url, requestFacade, nettyHttpResponse, serviceDeployer, restResponseFilters);
|
||||
} catch (Throwable throwable) {
|
||||
logger.error("", throwable.getMessage(), "", "dubbo rest protocol provider error ,and raw request is " + nettyHttpRequest, throwable);
|
||||
nettyHttpResponse.sendError(500, "dubbo rest invoke Internal error, message is " + throwable.getMessage() + " ,and exception type is : " + throwable.getClass()
|
||||
+ " , stacktrace is: " + ServiceInvokeRestFilter.stackTraceToString(throwable));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue