File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
src/main/java/com/recordit/server/exception Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments