提交 250fbab8 编写于 作者: Z Zhangmei Li 提交者: Qi Luo

common: missing error checking in method KVDB::Has() and KVDB::Get()

Except NotFound error, there may be other errors when accessing leveldb Get(),
such as IOError.
上级 1124a44e
......@@ -86,7 +86,8 @@ bool KVDB::Has(const std::string &key) {
std::string value;
const auto status = GetDB()->Get(options, key, &value);
return !status.IsNotFound();
CHECK(status.ok() || status.IsNotFound()) << status.ToString();
return status.ok();
}
std::string KVDB::Get(const std::string &key,
......@@ -95,6 +96,7 @@ std::string KVDB::Get(const std::string &key,
std::string value;
const auto status = GetDB()->Get(options, key, &value);
CHECK(status.ok() || status.IsNotFound()) << status.ToString();
return status.ok() ? value : default_value;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册