mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
数值长度限制提示
This commit is contained in:
+5
-4
@@ -11,7 +11,7 @@ import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||
import com.cf.imes.framework.common.util.servlet.ServletUtils;
|
||||
import com.cf.imes.module.infra.api.logger.ApiErrorLogApi;
|
||||
import com.cf.imes.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
@@ -220,11 +220,12 @@ public class GlobalExceptionHandler {
|
||||
|
||||
Throwable rootCause = ex.getRootCause();
|
||||
// 无效格式异常处理。
|
||||
if (rootCause instanceof MismatchedInputException) {
|
||||
return CommonResult.error(BAD_REQUEST.getCode(), "参数格式异常无法解读,请按照对应格式上传");
|
||||
if (rootCause instanceof InvalidFormatException) { // MismatchedInputException
|
||||
InvalidFormatException e = (InvalidFormatException) rootCause;
|
||||
return CommonResult.error(BAD_REQUEST.getCode(), String.format("参数校验失败:'%s' 格式出错", e.getValue()));
|
||||
}
|
||||
// 文件格式错误处理
|
||||
if (rootCause instanceof IOException ) {
|
||||
if (rootCause instanceof IOException) {
|
||||
// 使用正则提取数值
|
||||
Pattern pattern = Pattern.compile("Numeric value \\((\\d+)\\) out of range");
|
||||
Matcher matcher = pattern.matcher(rootCause.getMessage());
|
||||
|
||||
Reference in New Issue
Block a user