sitelink1 | |
---|---|
sitelink2 | |
sitelink3 | |
sitelink4 | |
sitelink5 | |
sitelink6 |
javax.crypto.BadPaddingException 라는 에러객체가 있다.
암호화 라이브러리를 사용하면서 암호화된 데이터를 복호화하지 못할때 발생하는 에러이다.
콘솔에서는 해당 Exception 을 상위로 throw 하면서 출력하게 되는 메세지가 꽤 상세하지만
Exceptoin 이 발생하는 블럭을 catch 하여 에러객체를 출력해보면 다음과 같은 메세지 한줄만 로그에 출력된다.
>> Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
에러가 발생하게 되는 근본적인 클래스와 이 에러가 전달되는 stacktrace 전체를 보고 싶은데
printStackTrace() 함수를 호출하는 것 외엔 방법이 없다.
getMessage() 나 toString() 으로는 도저히 전체 내용을 볼 수가 없었다.
콘솔에서나마 stacktrace 를 보고 싶다면 printStackTrace() 함수를 호출하고
로그에서는 에러를 캐치하여 getMessage() 로 에러를 출력후 적절한 추가 조치를 취하면 되겠다.
- 2024.07.06 추가 -
printStackTrace() 와 동일한 메세지를 반환 받을 수 있는 방법을 찾았다.
getStackTrace() 함수를 통해 StackTraceElement[] 배열을 반환 받은 후
배열을 순회하면서 객체의 toString() 을 출력하면 동일한 내용을 취할 수 있다.
이를 로그로 남기면 로그로써 에러를 추적하기가 쉬워진다.
public static String getStackTraceString(Exception e) {
StackTraceElement[] ste = e.getStackTrace();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < ste.length; i++) {
sb.append(System.lineSeparator() + ste[i].toString());
}
return sb.toString();
}
댓글 0
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
» | Exception 출력에 대한 고찰 | 황제낙엽 | 2024.06.10 | 177 |
7 | java.util.ConcurrentModificationException | 황제낙엽 | 2019.09.08 | 346 |
6 | java.lang.StackTraceElement Class의 내용 출력 | 황제낙엽 | 2019.07.03 | 453 |
5 | java.lang.IllegalArgumentException | 황제낙엽 | 2010.01.18 | 136071 |
4 | Error reading tld listeners java.lang.NullPointerException | 황제낙엽 | 2009.10.14 | 432 |
3 | Cannot find the tag library descriptor for “http://java.sun.com/jsp/jstl/core | 황제낙엽 | 2009.10.14 | 1246 |
2 | [javac 에러] code too large for try statement | 황제낙엽 | 2007.02.28 | 544 |
1 | NestedRuntimeException | 황제낙엽 | 2006.09.22 | 1331 |