Skip to content

Commit fe0800d

Browse files
authored
Merge pull request #17 from MBTips/feature/issue-15
feat : Exception 발생시 HttpStatus를 변환하여 반환
2 parents 63a379a + 094bb6d commit fe0800d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

api/src/main/java/com/mbtips/common/exception/handler/GlobalExceptionHandler.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.mbtips.common.exception.enums.CommonException;
55
import com.mbtips.common.response.ApiResponse;
66
import lombok.extern.slf4j.Slf4j;
7+
import org.springframework.http.ResponseEntity;
78
import org.springframework.validation.FieldError;
89
import org.springframework.web.bind.MethodArgumentNotValidException;
910
import org.springframework.web.bind.annotation.ExceptionHandler;
@@ -17,21 +18,21 @@
1718
public class GlobalExceptionHandler {
1819

1920
@ExceptionHandler(CustomException.class)
20-
public ApiResponse<Void> customExceptionHandler(CustomException e) {
21+
public ResponseEntity<Void> customExceptionHandler(CustomException e) {
2122
log.error("### CustomExceptionHandler : {}", e.getMessage(), e);
22-
return ApiResponse.fail(e.getException());
23+
return ResponseEntity.internalServerError().build();
2324
}
2425

2526
@ExceptionHandler(IllegalArgumentException.class)
26-
public ApiResponse<Void> exceptionHandler(IllegalArgumentException e) {
27+
public ResponseEntity<Void> exceptionHandler(IllegalArgumentException e) {
2728
log.error("### IllegalArgumentExceptionHandler : {}", e.getMessage(), e);
28-
return ApiResponse.fail(CommonException.INVALID_REQUEST_ERROR);
29+
return ResponseEntity.badRequest().build();
2930
}
3031

3132
@ExceptionHandler(Exception.class)
32-
public ApiResponse<Void> exceptionHandler(Exception e) {
33+
public ResponseEntity<Void> exceptionHandler(Exception e) {
3334
log.error("### ExceptionHandler : {}", e.getMessage(), e);
34-
return ApiResponse.fail(CommonException.INTERNAL_SERVER_ERROR);
35+
return ResponseEntity.internalServerError().build();
3536
}
3637

3738
/**

0 commit comments

Comments
 (0)