fix: 添加数据格式错误异常的友好提示
This commit is contained in:
parent
313ffc9532
commit
f4846bdc07
|
|
@ -1,6 +1,7 @@
|
||||||
package com.nflg.product.base.core.exception;
|
package com.nflg.product.base.core.exception;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import nflg.product.common.constant.STATE;
|
import nflg.product.common.constant.STATE;
|
||||||
import nflg.product.common.vo.ResultVO;
|
import nflg.product.common.vo.ResultVO;
|
||||||
|
|
@ -167,4 +168,12 @@ public class BaseGlobalExceptionHandle {
|
||||||
//return ResultVO.error(e.getState(), e.getMessage());
|
//return ResultVO.error(e.getState(), e.getMessage());
|
||||||
return ResultVO.error(e.getState(), e.getMessage(), e.getData());
|
return ResultVO.error(e.getState(), e.getMessage(), e.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(value = InvalidFormatException.class)
|
||||||
|
@ResponseBody
|
||||||
|
public ResultVO handleInvalidFormatException(ErrorMsgException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
//return ResultVO.error(e.getState(), e.getMessage());
|
||||||
|
return ResultVO.error(STATE.ParamErr, "数据格式错误,请修改后再提交: " + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue