Skip to content

Commit

Permalink
feat: exception logger 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
yesjuhee committed Jul 23, 2024
1 parent a6db839 commit 9ad8c11
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
Expand All @@ -16,6 +17,7 @@
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {

@Override
Expand All @@ -25,6 +27,8 @@ protected ResponseEntity<Object> handleMethodArgumentNotValid(
HttpStatusCode status,
WebRequest request) {

log.warn(ex.getMessage(), ex);

Map<String, Object> body = new HashMap<>();

body.put("status", 400);
Expand All @@ -42,6 +46,9 @@ protected ResponseEntity<Object> handleMethodArgumentNotValid(

@ExceptionHandler(BadRequestException.class)
public ResponseEntity<Object> handleBadRequestException(BadRequestException ex) {

log.warn(ex.getMessage(), ex);

Map<String, Object> body = new HashMap<>();

body.put("status", 400);
Expand Down

0 comments on commit 9ad8c11

Please sign in to comment.