展开全部
看你的子方法try..catch之后是否抛出去,如果636f70793231313335323631343130323136353331333363366239抛出去你的主程序就能捕获,否则就被你的子程序将异常吃掉了:
子程序抛出异常,主程序可以捕获:public class Test {
public static void exceptionTest() throws Exception{
try{
// xxx
}catch(Exception e){
throw new Exception("子方法抛出异常");
}
}
public static void main(String[] args) {
try {
Test.exceptionTest();
} catch (Exception e) {
System.out.println("主方法捕获异常");
}
}
}
子程序吃掉异常,主程序不能捕获:public class Test {
public static void exceptionTest() throws Exception{
try{
// xxx
}catch(Exception e){
//吃掉异常
}
}
public static void main(String[] args) {
try {
Test.exceptionTest();
} catch (Exception e) {
System.out.println("主方法捕获异常");
}
}
}