参数校验
This commit is contained in:
@ -6,6 +6,8 @@ import com.greenorange.promotion.common.ResultUtils;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sf.jsqlparser.util.validation.ValidationError;
|
||||
import org.springframework.dao.InvalidDataAccessResourceUsageException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.validation.BindingResult;
|
||||
@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
@ -60,7 +63,6 @@ public class GlobalExceptionHandler {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 处理业务异常
|
||||
@ExceptionHandler(BusinessException.class)
|
||||
public BaseResponse<?> businessExceptionHandler(BusinessException e) {
|
||||
@ -69,11 +71,14 @@ public class GlobalExceptionHandler {
|
||||
}
|
||||
|
||||
|
||||
// // 处理运行时异常
|
||||
// @ExceptionHandler(RuntimeException.class)
|
||||
// public BaseResponse<?> runtimeExceptionHandler(RuntimeException e) {
|
||||
// log.error("RuntimeException", e);
|
||||
// return ResultUtils.error(ErrorCode.SYSTEM_ERROR, "系统错误");
|
||||
// }
|
||||
// 处理 SQL 语法错误
|
||||
@ExceptionHandler(SQLException.class)
|
||||
public BaseResponse<?> handleSQLException(SQLException ex) {
|
||||
// 记录详细的 SQL 错误信息
|
||||
log.error("SQL 错误: " + ex.getMessage());
|
||||
return ResultUtils.error(ErrorCode.DATABASE_ERROR, "SQL语法错误,详细信息:" + ex.getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user