wcc1433 opened a new issue, #10314:
URL: https://github.com/apache/dubbo/issues/10314
想定义一个 provider端的 filter,将业务异常封装之后返回 {"code": 500, "msg": "xxx"}给
consumer端。但是在网上找到的都是通过 spring aop的方式进行处理的。
下面是我自己的一个示例(不知道怎么封装成 result):
@Activate(group = {CommonConstants.PROVIDER}, order = -2)
public class ExceptionFilter implements Filter {
@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws
RpcException {
Result result = invoker.invoke(invocation);
if (result.getException() instanceof BaseException) {
// 判断抛出的异常是否为业务异常
BaseException exception = (BaseException) result.getException();
result = ???
} else if (result.getException() instanceof Exception) {
result = ???
}
return result;
}
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]