예외(Exception)가 발생하여 자바 콘솔에 발생하는 에러 로그(StackTrace)에 대해 기본적인 흐름를 알고자 기본적인 코드를 작성하여 공부해보았습니다.
package my.exception;
public class Main {
static void method1() {
try {
method2();
} catch (Exception e) {
System.out.print("caused by: ");
e.printStackTrace();
throw new RuntimeException();
}
}
static void method2() {
try {
method3();
} catch (Exception e) {
System.out.print("caused by: ");
e.printStackTrace();
throw new NullPointerException();
}
}
static void method3() throws Exception {
System.out.println(1 / 0);
}
public static void main(String[] args) {
method1();
}
}
https://okky.kr/article/338405
StackTrace 읽는 법에 대한 내용으로, 위 글을 강력 추천드립니다.