-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
1. ErrorDTO에 detail 부분 삭제 2. 에러 전, log.warn 추가 3. DTO 타입 Record 타입으로 통일
- Loading branch information
1 parent
48fc981
commit 0dfc96f
Showing
3 changed files
with
9 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/java/com/compono/ibackend/common/handler/CustomExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
package com.compono.ibackend.common.handler; | ||
|
||
import com.compono.ibackend.common.dto.error.response.ErrorDTO; | ||
import com.compono.ibackend.common.enumType.ErrorCode; | ||
import com.compono.ibackend.common.exception.CustomException; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
|
||
@Slf4j | ||
@ControllerAdvice | ||
public class CustomExceptionHandler { | ||
|
||
@ExceptionHandler(CustomException.class) | ||
protected ResponseEntity<ErrorDTO> handleCustom400Exception(CustomException ex) { | ||
ErrorCode errorCode = ex.getErrorCode(); | ||
log.warn(String.format("http-status={%d} code={%d} msg={%s}", ex.getStatus().value(), errorCode.getCode(), | ||
errorCode.getMsg())); | ||
|
||
return ErrorDTO.toResponseEntity(ex); | ||
} | ||
} |