diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-05-02 15:16:55 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-05-02 15:17:14 +0200 |
commit | 9eb1e1e8ce2ba5c2d0bb94b7fd9c028a5da0978a (patch) | |
tree | f4d3fab02b9e111042f5616a3454f419ec11e8c9 | |
parent | 51cb8fe870bd7a0bd61340307f2310316c8e7c55 (diff) | |
parent | 2fdd4c793347843a450f26aa238b62a239bbb261 (diff) |
Merge pull request #3602
2fdd4c7 better std::exception logging for CAddrDb (Philip Kaufmann)
-rw-r--r-- | src/net.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/net.cpp b/src/net.cpp index a73ff73ebd..6369dd2924 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1944,21 +1944,21 @@ bool CAddrDB::Write(const CAddrMan& addr) FILE *file = fopen(pathTmp.string().c_str(), "wb"); CAutoFile fileout = CAutoFile(file, SER_DISK, CLIENT_VERSION); if (!fileout) - return error("CAddrman::Write() : open failed"); + return error("%s : Failed to open file %s", __func__, pathTmp.string()); // Write and commit header, data try { fileout << ssPeers; } catch (std::exception &e) { - return error("CAddrman::Write() : I/O error"); + return error("%s : Serialize or I/O error - %s", __func__, e.what()); } FileCommit(fileout); fileout.fclose(); // replace existing peers.dat, if any, with new peers.dat.XXXX if (!RenameOver(pathTmp, pathAddr)) - return error("CAddrman::Write() : Rename-into-place failed"); + return error("%s : Rename-into-place failed", __func__); return true; } @@ -1969,13 +1969,14 @@ bool CAddrDB::Read(CAddrMan& addr) FILE *file = fopen(pathAddr.string().c_str(), "rb"); CAutoFile filein = CAutoFile(file, SER_DISK, CLIENT_VERSION); if (!filein) - return error("CAddrman::Read() : open failed"); + return error("%s : Failed to open file %s", __func__, pathAddr.string()); // use file size to size memory buffer int fileSize = boost::filesystem::file_size(pathAddr); int dataSize = fileSize - sizeof(uint256); // Don't try to resize to a negative number if file is small - if ( dataSize < 0 ) dataSize = 0; + if (dataSize < 0) + dataSize = 0; vector<unsigned char> vchData; vchData.resize(dataSize); uint256 hashIn; @@ -1986,7 +1987,7 @@ bool CAddrDB::Read(CAddrMan& addr) filein >> hashIn; } catch (std::exception &e) { - return error("CAddrman::Read() 2 : I/O error or stream data corrupted"); + return error("%s : Deserialize or I/O error - %s", __func__, e.what()); } filein.fclose(); @@ -1995,7 +1996,7 @@ bool CAddrDB::Read(CAddrMan& addr) // verify stored checksum matches input data uint256 hashTmp = Hash(ssPeers.begin(), ssPeers.end()); if (hashIn != hashTmp) - return error("CAddrman::Read() : checksum mismatch; data corrupted"); + return error("%s : Checksum mismatch, data corrupted", __func__); unsigned char pchMsgTmp[4]; try { @@ -2004,13 +2005,13 @@ bool CAddrDB::Read(CAddrMan& addr) // ... verify the network matches ours if (memcmp(pchMsgTmp, Params().MessageStart(), sizeof(pchMsgTmp))) - return error("CAddrman::Read() : invalid network magic number"); + return error("%s : Invalid network magic number", __func__); // de-serialize address data into one CAddrMan object ssPeers >> addr; } catch (std::exception &e) { - return error("CAddrman::Read() : I/O error or stream data corrupted"); + return error("%s : Deserialize or I/O error - %s", __func__, e.what()); } return true; |