Skip to content

Commit f8426a0

Browse files
authored
release: 1.1.0 (#119)
2 parents 8fab30d + 4a7df4a commit f8426a0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/main/kotlin/org/gitanimals/core/advice/GlobalExceptionHandler.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import org.springframework.web.bind.MissingRequestHeaderException
88
import org.springframework.web.bind.annotation.ExceptionHandler
99
import org.springframework.web.bind.annotation.ResponseStatus
1010
import org.springframework.web.bind.annotation.RestControllerAdvice
11+
import java.lang.Exception
1112

1213
@RestControllerAdvice
1314
class 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
}

0 commit comments

Comments
 (0)