本文整理汇总了C++中leveldb::Status::IsCorruption方法的典型用法代码示例。如果您正苦于以下问题:C++ Status::IsCorruption方法的具体用法?C++ Status::IsCorruption怎么用?C++ Status::IsCorruption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类leveldb::Status
的用法示例。
在下文中一共展示了Status::IsCorruption方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleError
void HandleError(const leveldb::Status &status) throw(leveldb_error) {
if (status.ok())
return;
if (status.IsCorruption())
throw leveldb_error("Database corrupted");
if (status.IsIOError())
throw leveldb_error("Database I/O error");
if (status.IsNotFound())
throw leveldb_error("Database entry missing");
throw leveldb_error("Unknown database error");
}
示例2: HandleError
void HandleError(const leveldb::Status &status) noexcept(false) {
if (status.ok())
return;
LogPrintf("%s\n", status.ToString());
if (status.IsCorruption())
throw leveldb_error("Database corrupted");
if (status.IsIOError())
throw leveldb_error("Database I/O error");
if (status.IsNotFound())
throw leveldb_error("Database entry missing");
throw leveldb_error("Unknown database error");
}
示例3: process_status
bool KeyValueStorage::process_status(const leveldb::Status & status, bool reopen) {
if (status.ok()) {
return true;
}
std::lock_guard<Mutex> lock(mutex);
error = status.ToString();
if (status.IsCorruption()) {
if (++repairs > 2)
return false;
errorstream << "Trying to repair database [" << db_name << "] try=" << repairs << " [" << error << "]" << std::endl;
leveldb::Options options;
options.create_if_missing = true;
leveldb::Status status_repair;
try {
status_repair = leveldb::RepairDB(fullpath, options);
} catch (std::exception &e) {
errorstream << "First repair [" << db_name << "] exception [" << e.what() << "]" << std::endl;
auto options_repair = options;
options_repair.paranoid_checks = true;
try {
status_repair = leveldb::RepairDB(fullpath, options_repair);
} catch (std::exception &e) {
errorstream << "Second repair [" << db_name << "] exception [" << e.what() << "]" << std::endl;
}
}
if (!status.ok()) {
error = status.ToString();
errorstream << "Repair [" << db_name << "] fail [" << error << "]" << std::endl;
delete db;
db = nullptr;
return false;
}
if (reopen) {
auto status_open = leveldb::DB::Open(options, fullpath, &db);
if (!status_open.ok()) {
error = status_open.ToString();
errorstream << "Trying to reopen database [" << db_name << "] fail [" << error << "]" << std::endl;
delete db;
db = nullptr;
return false;
}
}
}
return status.ok();
}
示例4: make_status_tuple
extern ERL_NIF_TERM make_status_tuple(ErlNifEnv* env, leveldb::Status status){
const char* type;
if(status.IsNotFound()){
type = "not_found";
}
else if(status.IsCorruption()){
type = "corruption";
}
else if(status.IsIOError()){
type = "io_error";
}
else{
type = "unspecified";
}
const char* stString = status.ToString().c_str();
return enif_make_tuple2(env, enif_make_atom(env, "error"),
enif_make_atom(env, type));
}
示例5: checkDbError
void LevelDB::checkDbError(leveldb::Status aStatus) throw(DbException) {
if (aStatus.ok())
return;
if (aStatus.IsNotFound())
return;
string ret = Text::toUtf8(aStatus.ToString());
#ifdef _WIN32
if (aStatus.IsCorruption() || aStatus.IsIOError()) {
if (ret.back() != '.')
ret += ".";
ret += " " + STRING_F(DB_ERROR_HINT, STRING(HASHING));
}
#endif
throw DbException(ret);
}