Skip to content

Commit

Permalink
Merge pull request #156 from jhy0285/code_convention
Browse files Browse the repository at this point in the history
#151 Feat: 경로변수 예외 처리 구현
  • Loading branch information
jhy0285 authored Nov 2, 2023
2 parents 0391b29 + 377a8c4 commit dc661ba
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 dc661ba

Please sign in to comment.