Skip to content

Commit

Permalink
Chore: 잘못된 requestParam 들어온 경우 예외 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-haeseung committed Dec 8, 2024
1 parent c529e14 commit fd15901
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Map;
import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.TypeMismatchException;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
Expand Down Expand Up @@ -53,6 +54,22 @@ public ResponseEntity<Object> handleMethodArgumentNotValid(
return handleExceptionInternalArgs(e,HttpHeaders.EMPTY, ErrorStatus.valueOf("_BAD_REQUEST"),request,errors);
}

@Override
protected ResponseEntity<Object> handleTypeMismatch(
TypeMismatchException e, HttpHeaders headers, HttpStatusCode status, WebRequest request) {

ErrorStatus errorStatus = ErrorStatus._BAD_REQUEST;
ApiResponse<Object> body = ApiResponse.onFailure(errorStatus.getCode(), e.getMessage(), null);

return super.handleExceptionInternal(
e,
body,
HttpHeaders.EMPTY,
errorStatus.getHttpStatus(),
request
);
}

@ExceptionHandler
public ResponseEntity<Object> exception(Exception e, WebRequest request) {
e.printStackTrace();
Expand Down

0 comments on commit fd15901

Please sign in to comment.