Programming/JAVA/JSP
[Java] 개발자가 직접 Exception 발생 시키기
현수림
2009. 4. 3. 20:00
출처 : http://yosh.tistory.com/164
소스상에서 아래와 같이 코딩한다.
public class testClass{
public String testMethod(String msg) throws Exception {
... 생략 ...
try {
throw new Exception("Exception 메세지 내용 입력");
} catch(Exception e) {
e.printStackTrace();
}
}
}
public String testMethod(String msg) throws Exception {
... 생략 ...
try {
throw new Exception("Exception 메세지 내용 입력");
} catch(Exception e) {
e.printStackTrace();
}
}
}
이렇게 하고 stdout.log 파일을 열어보면 아래와 같이 나올것이다.
java.lang.Exception: !!!!test!!!!
at com.testClass.execute(VmRequestAction.java:38)
... 생략 ...
2009. 4. 3. 오후 7:24:30 org.apache.catalina.core.StandardContext reload
정보: Reloading this Context has started
2009. 4. 3. 오후 7:24:30 org.apache.catalina.logger.LoggerBase stop
정보: unregistering logger Catalina:type=Logger,path=/,host=localhost
at com.testClass.execute(VmRequestAction.java:38)
... 생략 ...
2009. 4. 3. 오후 7:24:30 org.apache.catalina.core.StandardContext reload
정보: Reloading this Context has started
2009. 4. 3. 오후 7:24:30 org.apache.catalina.logger.LoggerBase stop
정보: unregistering logger Catalina:type=Logger,path=/,host=localhost
보다 자세한 정보는 링크 걸린 페이지에 가면 얻을 수 있다.