Skip to content

Commit 6fff616

Browse files
authored
Merge pull request #50 from ItRecode/feature/BE-91
[BE-91] GlobalExceptionHandler에 Validation 예외 추가
2 parents e042343 + a498d05 commit 6fff616

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.recordit.server.exception;
2+
3+
import org.springframework.http.HttpStatus;
4+
import org.springframework.http.ResponseEntity;
5+
import org.springframework.web.bind.MethodArgumentNotValidException;
6+
import org.springframework.web.bind.annotation.ExceptionHandler;
7+
import org.springframework.web.bind.annotation.RestControllerAdvice;
8+
9+
import lombok.extern.slf4j.Slf4j;
10+
11+
@Slf4j
12+
@RestControllerAdvice
13+
public class GlobalExceptionHandler {
14+
@ExceptionHandler(MethodArgumentNotValidException.class)
15+
public ResponseEntity<ErrorMessage> handleMethodArgumentNotValidException(
16+
MethodArgumentNotValidException exception) {
17+
return ResponseEntity.badRequest()
18+
.body(ErrorMessage.of(exception, HttpStatus.BAD_REQUEST));
19+
}
20+
}

0 commit comments

Comments
 (0)