旗开得胜
This commit is contained in:
@ -6,6 +6,7 @@ import com.greenorange.promotion.common.ResultUtils;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.validation.ObjectError;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
@ -23,14 +24,14 @@ public class GlobalExceptionHandler {
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public BaseResponse<?> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
|
||||
log.error("MethodArgumentNotValidException", e);
|
||||
return ResultUtils.error(ErrorCode.PARAMS_ERROR, "参数验证失败");
|
||||
return ResultUtils.error(ErrorCode.PARAMS_ERROR, e.getMessage());
|
||||
}
|
||||
|
||||
// 处理消息体解析失败的异常
|
||||
@ExceptionHandler(HttpMessageNotReadableException.class)
|
||||
public BaseResponse<?> handleHttpMessageNotReadableException(HttpMessageNotReadableException e) {
|
||||
log.error("HttpMessageNotReadableException", e);
|
||||
return ResultUtils.error(ErrorCode.PARAMS_ERROR, "请求参数不正确");
|
||||
return ResultUtils.error(ErrorCode.PARAMS_ERROR, e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user