File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
src/main/kotlin/org/gitanimals/core/advice Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import org.springframework.web.bind.MissingRequestHeaderException
88import org.springframework.web.bind.annotation.ExceptionHandler
99import org.springframework.web.bind.annotation.ResponseStatus
1010import org.springframework.web.bind.annotation.RestControllerAdvice
11+ import java.lang.Exception
1112
1213@RestControllerAdvice
1314class GlobalExceptionHandler {
@@ -30,4 +31,18 @@ class GlobalExceptionHandler {
3031 logger.error(exception.message, exception)
3132 return ErrorResponse .from(exception)
3233 }
34+
35+ @ResponseStatus(HttpStatus .BAD_REQUEST )
36+ @ExceptionHandler(IllegalArgumentException ::class )
37+ fun handleIllegalArgumentException (exception : IllegalArgumentException ): ErrorResponse {
38+ logger.error(exception.message, exception)
39+ return ErrorResponse .from(exception)
40+ }
41+
42+ @ExceptionHandler(Exception ::class )
43+ @ResponseStatus(HttpStatus .INTERNAL_SERVER_ERROR )
44+ fun handleAllUnHandledException (exception : Exception ): ErrorResponse {
45+ logger.error(exception.message, exception)
46+ return ErrorResponse (" UN HANDLED EXCEPTION" )
47+ }
3348}
You can’t perform that action at this time.
0 commit comments