Skip to content

Commit

Permalink
#151 Feat: 경로변수 예외 처리 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
jhy0285 committed Nov 2, 2023
1 parent 76def5e commit 377a8c4
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import com.kakao.linknamu.core.util.ApiUtils;

import jakarta.validation.ConstraintViolationException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

Expand All @@ -23,6 +24,12 @@

public class GlobalExceptionHandler {

@ExceptionHandler({ConstraintViolationException.class})
public ResponseEntity<?> pathVarValidationException(ConstraintViolationException e) {
ApiUtils.ApiResult<?> apiResult = ApiUtils.error(e.getMessage(), HttpStatus.BAD_REQUEST.value());
return new ResponseEntity<>(apiResult, HttpStatus.BAD_REQUEST);
}

@ExceptionHandler({MethodArgumentNotValidException.class})
public ResponseEntity<?> dtoValidationException(MethodArgumentNotValidException e) {
List<ObjectError> errors = e.getBindingResult().getAllErrors();
Expand Down

0 comments on commit 377a8c4

Please sign in to comment.