문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 다음 판 | 이전 판 | ||
|
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.tostring_e.getmessage_e.printstacktrace_의_차이점 ====== |
| + | <WRAP left notice 80%> | ||
| + | * description : | ||
| + | * author | ||
| + | * email : hylee@repia.com | ||
| + | * lastupdate | ||
| + | </ | ||
| + | <WRAP clear/> | ||
| + | ===== 작성 이유 ===== | ||
| + | |||
| + | * 내부 프로젝트들을 진행하면서 에러로그가 중요하단걸 느꼈습니다. | ||
| + | * 에러 로그를 잘 보려면 예외가 발생할 곳에 'try{} catch(){}' | ||
| + | * ' | ||
| + | |||
| + | ===== Excqption e 메세지 기능 ===== | ||
| + | |||
| + | * e.getMessage() : 에러 이벤트와 함께 들어오는 메세지 출력 | ||
| + | * e.toString() : 에러 이벤트의 toString()을 호출해서 간단한 에러 메시지 확인 | ||
| + | * e.printStackTrace() : 에러 메세지의 발생 근원지를 찾아 단계별로 에러 출력 | ||
| + | |||
| + | ===== Java 예제 ===== | ||
| + | <code java> | ||
| + | public class ExeThrowException { | ||
| + | | ||
| + | try{ | ||
| + | // | ||
| + | throw new Exception(" | ||
| + | }catch(Exception e){ | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | <code console> | ||
| + | e.getMessage() = 에러내용입니다. | ||
| + | e.toString() = java.lang.Exception: | ||
| + | e.printStackTrace() = java.lang.Exception: | ||
| + | at ExeThrowException.main(ExeThrowException.java: | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ===== Ref ===== | ||
| + | * [[https:// | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | {{tag> | ||