사용자 도구

사이트 도구


wiki:java:e.tostring_e.getmessage_e.printstacktrace_의_차이점

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

다음 판
이전 판
wiki:java:e.tostring_e.getmessage_e.printstacktrace_의_차이점 [2020/04/23 13:15]
hylee 만듦
wiki:java:e.tostring_e.getmessage_e.printstacktrace_의_차이점 [2023/01/13 18:44] (현재)
줄 1: 줄 1:
-e.toString(), e.getMessage(), e.printStackTrace()의 차이점+====== e.tostring_e.getmessage_e.printstacktrace_의_차이점 ====== 
 +<WRAP left notice 80%> 
 +  * description :  
 +  * author      : 도봉산핵주먹 
 +  * email       : hylee@repia.com 
 +  * lastupdate  : 2020-04-23 
 +</WRAP> 
 +<WRAP clear/> 
 +===== 작성 이유 ===== 
 + 
 +  * 내부 프로젝트들을 진행하면서 에러로그가 중요하단걸 느꼈습니다. 
 +  * 에러 로그를 잘 보려면 예외가 발생할 곳에 'try{} catch(){}'를 잘 써야됩니다. 
 +  * 'catch(Excaption e)'에 'Excaptio e'의 에러내용을 잘 출력해서 봐야됩니다. 
 + 
 +===== Excqption e 메세지 기능 ===== 
 + 
 +  * e.getMessage() : 에러 이벤트와 함께 들어오는 메세지 출력 
 +  * e.toString() : 에러 이벤트의 toString()을 호출해서 간단한 에러 메시지 확인 
 +  * e.printStackTrace() : 에러 메세지의 발생 근원지를 찾아 단계별로 에러 출력 
 + 
 +===== Java 예제 ===== 
 +<code java> 
 +public class ExeThrowException { 
 +   public static void main (String args[]){ 
 +      try{ 
 +         //메시지와 함께 수동으로 에러 이벤트 발생 
 +         throw new Exception("에러내용입니다."); 
 +      }catch(Exception e){ 
 +         System.out.println("e.getMessage() = " + e.getMessage()); 
 +         System.out.println("e.toString() = " + e.toString()); 
 +         e.printStackTrace(); 
 +         return; 
 +      } 
 +   } 
 +
 +</code> 
 + 
 +<code console> 
 +e.getMessage() = 에러내용입니다. 
 +e.toString() = java.lang.Exception: 에러내용입니다. 
 +e.printStackTrace() = java.lang.Exception: 에러내용입니다. 
 +              at ExeThrowException.main(ExeThrowException.java:5) 
 +</code> 
 + 
 + 
 + 
 + 
 +===== Ref ===== 
 +  * [[https://passionha.tistory.com/146|e.toString(), e.getMessage(), e.printStackTrace()의 차이점]]  
 + 
 + 
 + 
 + 
 + 
 + 
 +{{tag>도봉산핵주먹 예외처리 e.printStackTrace() e.getMessage() e.toString()}}
/volume1/web/dokuwiki/data/attic/wiki/java/e.tostring_e.getmessage_e.printstacktrace_의_차이점.1587615358.txt.gz · 마지막으로 수정됨: 2022/03/10 19:52 (바깥 편집)