
// UsingStackTrace.java
// Andrew Davison, Jan 2018, ad@fivedots.coe.psu.ac.th

// Demonstrating the getMessage and printStackTrace
// methods inherited into all exception classes.


public class UsingStackTrace
{
  public static void main(String args[])
  {
    try {
      method1();
    }
    catch (Exception e) {
      System.err.println(e.getMessage() + "\n");
      e.printStackTrace();
    }
  }  // end of main()


  private static void method1() throws Exception
  { method2(); }

  private static void method2() throws Exception
  { method3(); }

  private static void method3() throws Exception
  {  throw new Exception("Exception thrown in method3"); }

}  // end of UsingStackTrace class

