参数校验

This commit is contained in:
2025-04-29 21:37:00 +08:00
parent 698b5b4504
commit 2ce8f06cfb
6 changed files with 28 additions and 30 deletions

View File

@ -47,10 +47,11 @@ public class GlobalExceptionHandler {
@ExceptionHandler(HttpMessageNotReadableException.class)
public BaseResponse<?> handleHttpMessageNotReadableException(HttpMessageNotReadableException e) {
log.error("HttpMessageNotReadableException", e);
return ResultUtils.error(ErrorCode.PARAMS_ERROR, e.getMessage());
return ResultUtils.error(ErrorCode.PARAMS_ERROR, "请求体不能为空或格式无效");
}
// 处理业务异常
@ExceptionHandler(BusinessException.class)
public BaseResponse<?> businessExceptionHandler(BusinessException e) {
log.error("BusinessException", e);
@ -58,6 +59,7 @@ public class GlobalExceptionHandler {
}
// 处理运行时异常
@ExceptionHandler(RuntimeException.class)
public BaseResponse<?> runtimeExceptionHandler(RuntimeException e) {
log.error("RuntimeException", e);