Skip to content

Commit

Permalink
chore: GlobalExceptionHandler 에서 error 로깅할 때 trace 는 출력하지 않도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
wjddn2165 committed Aug 21, 2024
1 parent fe7937e commit b586ae9
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ public class GlobalExceptionHandler {

@ExceptionHandler(CustomException.class)
public ResponseEntity<ErrorResponse> handler(CustomException e){
log.error("CustomException [{}]", e.getMessage(), e);
log.error("CustomException: {} {}", e.getErrorCode(), e.getMessage());
return ResponseEntity
.status(HttpStatus.valueOf(e.getErrorCode().getStatus()))
.body(ErrorResponse.of(e.getErrorCode(), e.getMessage()));
}

@ExceptionHandler(MethodArgumentNotValidException.class)
public ResponseEntity<ErrorResponse> methodArgumentNotValidExceptionHandler(MethodArgumentNotValidException e){
log.error("MethodArgumentNotValidException [{}]", e.getMessage(), e);
log.error("MethodArgumentNotValidException: [{}]", e.getMessage());

BindingResult bindingResult = e.getBindingResult();
StringBuilder builder = new StringBuilder();
Expand All @@ -43,15 +43,15 @@ public ResponseEntity<ErrorResponse> methodArgumentNotValidExceptionHandler(Meth

@ExceptionHandler(RuntimeException.class)
public ResponseEntity<ErrorResponse> runtimeExceptionHandler(RuntimeException e){
log.error("RuntimeException [{}]", e.getMessage(), e);
log.error("RuntimeException: [{}]", e.getMessage());
return ResponseEntity
.status(HttpStatus.BAD_REQUEST)
.body(ErrorResponse.of(CustomErrorCode.BAD_REQUEST, e.getMessage()));
}

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

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

0 comments on commit b586ae9

Please sign in to comment.