From 047178d70da376e281c62299805ea23782a2f601 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Tue, 17 Oct 2023 18:33:46 +0800 Subject: [PATCH] Add HttpRequestMethodNotSupportedException catch --- src/main/kotlin/top/fatweb/api/handler/ExceptionHandler.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/kotlin/top/fatweb/api/handler/ExceptionHandler.kt b/src/main/kotlin/top/fatweb/api/handler/ExceptionHandler.kt index 585f04b..98c0bbf 100644 --- a/src/main/kotlin/top/fatweb/api/handler/ExceptionHandler.kt +++ b/src/main/kotlin/top/fatweb/api/handler/ExceptionHandler.kt @@ -9,6 +9,7 @@ import org.springframework.http.converter.HttpMessageNotReadableException import org.springframework.security.authentication.BadCredentialsException import org.springframework.security.authentication.InsufficientAuthenticationException import org.springframework.security.authentication.InternalAuthenticationServiceException +import org.springframework.web.HttpRequestMethodNotSupportedException import org.springframework.web.bind.MethodArgumentNotValidException import org.springframework.web.bind.annotation.ExceptionHandler import org.springframework.web.bind.annotation.RestControllerAdvice @@ -28,6 +29,11 @@ class ExceptionHandler { ResponseResult.fail(ResponseCode.SYSTEM_UNAUTHORIZED, e.localizedMessage, null) } + is HttpRequestMethodNotSupportedException -> { + logger.debug(e.localizedMessage, e) + ResponseResult.fail(ResponseCode.SYSTEM_REQUEST_ILLEGAL, e.localizedMessage, null) + } + is HttpMessageNotReadableException -> { logger.debug(e.localizedMessage, e) ResponseResult.fail(ResponseCode.SYSTEM_REQUEST_ILLEGAL, e.localizedMessage.split(":")[0], null)