try catch 不起作用

来源:互联网 发布:vc界面编程经典实例 编辑:程序博客网 时间:2024/06/07 21:54

问题:

       bytes = infOutSystemService.applyExecute(str.getBytes()); // bubbo方法调用异常

增加 try catch 后依然没有打印错误              

        try {
bytes = infOutSystemService.applyExecute(str.getBytes());
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}

原因:dubbo 接口只处理了Excption, 没有处理Error, 所以没有返回报文, 直接把Error抛出来了。

解决方案:

        如需要捕获error的话,采用throwable

try {

bytes = infOutSystemService.applyExecute(str.getBytes());
} catch (Throwable e) {
// TODO: handle exception
e.printStackTrace();
}

原创粉丝点击