Exception(예외)
Java 에서 발생하는 예외에 대해서 알아보고 해결 방법에 대해 알아보자
Last updated
int maxretry = MAX_RETRY;
while(maxretry -- > 0) {
try {
// 예외가 발생할 가능성이 있는 시도
return; // 작업성공시 리턴
}
catch (SomeException e) {
// 로그 출력. 정해진 시간만큼 대기
}
finally {
// 리소스 반납 및 정리 작업
}
}
throw new RetryFailedException(); // 최대 재시도 횟수를 넘기면 직접 예외 발생public void add() throws SQLException {
... // 구현 로직
}catch(SQLException e) {
...
throw DuplicateUserIdException();
}