コード例 #1
0
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
0
ファイル: leveldbwrapper.cpp プロジェクト: aurarad/Auroracoin
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
0
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));
}
コード例 #4
0
static void histogramLevelDBError(const char* histogramName, const leveldb::Status& s)
{
    ASSERT(!s.ok());
    enum {
        LevelDBNotFound,
        LevelDBCorruption,
        LevelDBIOError,
        LevelDBOther,
        LevelDBMaxError
    };
    int levelDBError = LevelDBOther;
    if (s.IsNotFound())
        levelDBError = LevelDBNotFound;
    else if (s.IsCorruption())
        levelDBError = LevelDBCorruption;
    else if (s.IsIOError())
        levelDBError = LevelDBIOError;
    HistogramSupport::histogramEnumeration(histogramName, levelDBError, LevelDBMaxError);
}
コード例 #5
0
ファイル: LevelDB.cpp プロジェクト: airdcnano/airdcnano
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);
}