package?com.H.test;
public?class?ChainTest?{
????public?static?void?main(String[]?args)?{
ChainTest?ct=new?ChainTest();
?try?{
?????ct.test2();
?}catch?(Exception?e){
?????e.printStackTrace();
?}
????}
????public??void??test1()throws?DrunkException{
????????throw?new?RuntimeException("喝酒別開車!");
????}
????public?void?test2(){
????????try?{
????????????test1();
????????}?catch?(DrunkException?e)?{
????????????RuntimeException?newExc=new?RuntimeException("司機一滴酒");
????????????newExc.initCause(e);
????????????throw?newExc;
????????}
????}
}
2022-04-28