diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2013-08-15 19:02:32 -0700 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2013-08-15 19:02:32 -0700 |
commit | 31b28082fe984990a251aa1a05cb4c4457edd310 (patch) | |
tree | da12f6dc32efe3c233436fabd7e1e7b1d1f5be94 /src | |
parent | 3f20f8220918c34ea734e943b7d8c281ad33040c (diff) | |
parent | b35e99320001fe2efdd96cd35b0170e30773bd09 (diff) |
Merge pull request #2891 from gavinandresen/leveldb_printerror
Use HandleError() consistently to handle leveldb errors
Diffstat (limited to 'src')
-rw-r--r-- | src/init.cpp | 1 | ||||
-rw-r--r-- | src/leveldb.cpp | 10 |
2 files changed, 4 insertions, 7 deletions
diff --git a/src/init.cpp b/src/init.cpp index 9f3d526414..7182c14146 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -778,6 +778,7 @@ bool AppInit2(boost::thread_group& threadGroup) break; } } catch(std::exception &e) { + if (fDebug) printf("%s\n", e.what()); strLoadError = _("Error opening block database"); break; } diff --git a/src/leveldb.cpp b/src/leveldb.cpp index e66f8514a7..5e3fa08f5e 100644 --- a/src/leveldb.cpp +++ b/src/leveldb.cpp @@ -15,6 +15,7 @@ void HandleError(const leveldb::Status &status) throw(leveldb_error) { if (status.ok()) return; + printf("%s\n", status.ToString().c_str()); if (status.IsCorruption()) throw leveldb_error("Database corrupted"); if (status.IsIOError()) @@ -54,8 +55,7 @@ CLevelDB::CLevelDB(const boost::filesystem::path &path, size_t nCacheSize, bool printf("Opening LevelDB in %s\n", path.string().c_str()); } leveldb::Status status = leveldb::DB::Open(options, path.string(), &pdb); - if (!status.ok()) - throw std::runtime_error(strprintf("CLevelDB(): error opening database environment %s", status.ToString().c_str())); + HandleError(status); printf("Opened LevelDB successfully\n"); } @@ -72,10 +72,6 @@ CLevelDB::~CLevelDB() { bool CLevelDB::WriteBatch(CLevelDBBatch &batch, bool fSync) throw(leveldb_error) { leveldb::Status status = pdb->Write(fSync ? syncoptions : writeoptions, &batch.batch); - if (!status.ok()) { - printf("LevelDB write failure: %s\n", status.ToString().c_str()); - HandleError(status); - return false; - } + HandleError(status); return true; } |