如何跟踪异常的传播路径?

package we;
public class PrintExceptionStack {
public static void main( String args[] )
{
 try {
    method1();
 }
 catch ( Exception e ) {
    System.err.println( e.getMessage() + "\n" );
    e.printStackTrace();
 }
}

public static void method1() throws Exception
{
 method2();
}

public static void method2() throws Exception
{
 method3();
}

public static void method3() throws Exception
{
 throw new Exception( "Exception thrown in method3" );
}
}

 

posted @ 2019-11-03 21:43  明月照我还  阅读(140)  评论(0编辑  收藏  举报