额外的异常

This commit is contained in:
wangw 2025-11-12 13:38:13 +08:00
parent 89762d0589
commit 481b0202da
1 changed files with 10 additions and 0 deletions

View File

@ -12,6 +12,7 @@ import org.springframework.dao.DuplicateKeyException;
import org.springframework.http.HttpStatus;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.validation.ObjectError;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
@ -125,6 +126,15 @@ public class CzgControllerAdvice {
// return CzgResult.failure(CzgRespCode.PARAM_ERROR.getCode(), ex.getMessage());
// }
/**
* get/post 等方法不支持异常
*/
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public CzgResult<Object> handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException ex) {
return CzgResult.failure(CzgRespCode.UN_PERMISSION.getCode(), ex.getMessage());
}
/**
* 处理Hutool的校验工具类抛出异常
*/