Skip to content

Commit

Permalink
Merge pull request #208 from softeerbootcamp4th/feature/#203-rush-eve…
Browse files Browse the repository at this point in the history
…nt-apply-stress-test

feat: DB 관련 에러와 RuntimeException이 아닌 모든 Exception에 대해 로그를 남기도록 변경
  • Loading branch information
k000927 authored Aug 21, 2024
2 parents 546e563 + 9feeaee commit 112f211
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import JGS.CasperEvent.global.enums.CustomErrorCode;
import JGS.CasperEvent.global.error.exception.CustomException;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.exception.JDBCConnectionException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
Expand Down Expand Up @@ -48,4 +49,20 @@ public ResponseEntity<ErrorResponse> RuntimeExceptionHandler(RuntimeException e)
.body(ErrorResponse.of(CustomErrorCode.BAD_REQUEST, e.getMessage()));
}

@ExceptionHandler(JDBCConnectionException.class)
public ResponseEntity<ErrorResponse> handleJDBCConnectionException(JDBCConnectionException e) {
log.error("데이터베이스 연결 에러 [{}]", e.getMessage(), e);
return ResponseEntity
.status(HttpStatus.BAD_REQUEST)
.body(ErrorResponse.of(CustomErrorCode.BAD_REQUEST, e.getMessage()));

}

@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorResponse> handleAllExceptions(Exception e) {
log.error("예외 발생 [{}] ", e.getMessage(), e);
return ResponseEntity
.status(HttpStatus.BAD_REQUEST)
.body(ErrorResponse.of(CustomErrorCode.BAD_REQUEST, e.getMessage()));
}
}

0 comments on commit 112f211

Please sign in to comment.