optimize(ebom): 优化错误提示
This commit is contained in:
parent
5a78ef449a
commit
0e7cc1e877
|
|
@ -17,7 +17,9 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.multipart.MaxUploadSizeExceededException;
|
import org.springframework.web.multipart.MaxUploadSizeExceededException;
|
||||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||||
|
|
||||||
|
import java.sql.BatchUpdateException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.sql.SQLSyntaxErrorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 异常处理器
|
* 异常处理器
|
||||||
|
|
@ -171,9 +173,27 @@ public class BaseGlobalExceptionHandle {
|
||||||
|
|
||||||
@ExceptionHandler(value = InvalidFormatException.class)
|
@ExceptionHandler(value = InvalidFormatException.class)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResultVO handleInvalidFormatException(ErrorMsgException e) {
|
public ResultVO handleInvalidFormatException(InvalidFormatException e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
//return ResultVO.error(e.getState(), e.getMessage());
|
//return ResultVO.error(e.getState(), e.getMessage());
|
||||||
return ResultVO.error(STATE.ParamErr, "数据格式错误,请修改后再提交: " + e.getMessage());
|
return ResultVO.error(STATE.ParamErr, "数据格式错误,请修改后再提交: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(value = SQLSyntaxErrorException.class)
|
||||||
|
@ResponseBody
|
||||||
|
public ResultVO handleSQLSyntaxErrorException(SQLSyntaxErrorException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return ResultVO.error(STATE.ParamErr, "SQL语法错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(value = BatchUpdateException.class)
|
||||||
|
@ResponseBody
|
||||||
|
public ResultVO handleSQLSyntaxErrorException(BatchUpdateException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
if (StrUtil.isNotBlank(e.getMessage()) && e.getMessage().contains("Deadlock")) {
|
||||||
|
return ResultVO.error("操作失败,请重试");
|
||||||
|
} else {
|
||||||
|
return ResultVO.error("更新数据失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue