自定义异常链的内容
Excepnewx.initCause(e ); 是啥意思
Excepnewx.initCause(e ); 是啥意思
2015-11-07
楼上的同学已经说到了。大概的意思是:用t
public void test1()throws DrunkException{
throw new DrunkException("我是异常1号");
}
public void test2()throws{
try{
test1();
}catch(DrunkException e){
RunTimeException newExc = new RunTimeException("error……");
throw newExc;//如果你使用的是newExc.initCause(e);
}
}
//在mian函数中调用的话只会显示test2()方法中的RunTimeException:error……
//如果你使用的是newExc.initCause(e);会吧test1中DrunkException异常显示出来结果为:DrunkException:我是异常1号举报