반응형
여러 블로그 찾아봤는데 exception을 처리할 수 있는 클래스까지 만들어서 처리하는 방법만 가이드 하고 있었다.
신규 프로젝트야 클래스 만들어서 하면 되는데
레거시 시스템에서 클래스를 만들어 처리하기엔 영향도가 부담됐다.
가장 간단하게 예외를 처리할 수 있는 방법을 정리해둔다
try {
} catch(HttpClientErrorException hex) {
String statusCode = hex.getStatusCode().toString();
String responseBody = hex.getResponseBodyAsString();
} catch(HttpServerErrorException hex) {
String statusCode = hex.getStatusCode().toString();
String responseBody = hex.getResponseBodyAsString();
}
반응형
'Java Spring boot' 카테고리의 다른 글
mybatis sequence nextval 안돼서 PK 오류 발생 (0) | 2025.04.29 |
---|---|
ProcessException / ProcessMessageException (0) | 2025.03.19 |
Mybatis if문 동작 안함 (0) | 2024.12.06 |
Error Mybatis Mapped Statements collection does not contain value for (0) | 2024.12.04 |
java convert timestamp to datetime (0) | 2024.08.15 |