Skip to content

Commit fa785d1

Browse files
author
MarcoFalke
committed
Use __func__ to get function name for output printing
1 parent 7e5d94d commit fa785d1

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3954,7 +3954,7 @@ CBlockIndex * InsertBlockIndex(uint256 hash)
39543954
// Create new
39553955
CBlockIndex* pindexNew = new CBlockIndex();
39563956
if (!pindexNew)
3957-
throw runtime_error("LoadBlockIndex(): new CBlockIndex failed");
3957+
throw runtime_error(std::string(__func__) + ": new CBlockIndex failed");
39583958
mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first;
39593959
pindexNew->phashBlock = &((*mi).first);
39603960

src/primitives/transaction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ CAmount CTransaction::GetValueOut() const
100100
{
101101
nValueOut += it->nValue;
102102
if (!MoneyRange(it->nValue) || !MoneyRange(nValueOut))
103-
throw std::runtime_error("CTransaction::GetValueOut(): value out of range");
103+
throw std::runtime_error(std::string(__func__) + ": value out of range");
104104
}
105105
return nValueOut;
106106
}

src/wallet/wallet.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ CPubKey CWallet::GenerateNewKey()
108108

109109
// try to get the master key
110110
if (!GetKey(hdChain.masterKeyID, key))
111-
throw std::runtime_error("CWallet::GenerateNewKey(): Master key not found");
111+
throw std::runtime_error(std::string(__func__) + ": Master key not found");
112112

113113
masterKey.SetMaster(key.begin(), key.size());
114114

@@ -135,7 +135,7 @@ CPubKey CWallet::GenerateNewKey()
135135

136136
// update the chain model in the database
137137
if (!CWalletDB(strWalletFile).WriteHDChain(hdChain))
138-
throw std::runtime_error("CWallet::GenerateNewKey(): Writing HD chain model failed");
138+
throw std::runtime_error(std::string(__func__) + ": Writing HD chain model failed");
139139
} else {
140140
secret.MakeNewKey(fCompressed);
141141
}
@@ -152,7 +152,7 @@ CPubKey CWallet::GenerateNewKey()
152152
nTimeFirstKey = nCreationTime;
153153

154154
if (!AddKeyPubKey(secret, pubkey))
155-
throw std::runtime_error("CWallet::GenerateNewKey(): AddKey failed");
155+
throw std::runtime_error(std::string(__func__) + ": AddKey failed");
156156
return pubkey;
157157
}
158158

@@ -1094,7 +1094,7 @@ isminetype CWallet::IsMine(const CTxOut& txout) const
10941094
CAmount CWallet::GetCredit(const CTxOut& txout, const isminefilter& filter) const
10951095
{
10961096
if (!MoneyRange(txout.nValue))
1097-
throw std::runtime_error("CWallet::GetCredit(): value out of range");
1097+
throw std::runtime_error(std::string(__func__) + ": value out of range");
10981098
return ((IsMine(txout) & filter) ? txout.nValue : 0);
10991099
}
11001100

@@ -1123,7 +1123,7 @@ bool CWallet::IsChange(const CTxOut& txout) const
11231123
CAmount CWallet::GetChange(const CTxOut& txout) const
11241124
{
11251125
if (!MoneyRange(txout.nValue))
1126-
throw std::runtime_error("CWallet::GetChange(): value out of range");
1126+
throw std::runtime_error(std::string(__func__) + ": value out of range");
11271127
return (IsChange(txout) ? txout.nValue : 0);
11281128
}
11291129

@@ -1147,7 +1147,7 @@ CAmount CWallet::GetDebit(const CTransaction& tx, const isminefilter& filter) co
11471147
{
11481148
nDebit += GetDebit(txin, filter);
11491149
if (!MoneyRange(nDebit))
1150-
throw std::runtime_error("CWallet::GetDebit(): value out of range");
1150+
throw std::runtime_error(std::string(__func__) + ": value out of range");
11511151
}
11521152
return nDebit;
11531153
}
@@ -1159,7 +1159,7 @@ CAmount CWallet::GetCredit(const CTransaction& tx, const isminefilter& filter) c
11591159
{
11601160
nCredit += GetCredit(txout, filter);
11611161
if (!MoneyRange(nCredit))
1162-
throw std::runtime_error("CWallet::GetCredit(): value out of range");
1162+
throw std::runtime_error(std::string(__func__) + ": value out of range");
11631163
}
11641164
return nCredit;
11651165
}
@@ -1171,7 +1171,7 @@ CAmount CWallet::GetChange(const CTransaction& tx) const
11711171
{
11721172
nChange += GetChange(txout);
11731173
if (!MoneyRange(nChange))
1174-
throw std::runtime_error("CWallet::GetChange(): value out of range");
1174+
throw std::runtime_error(std::string(__func__) + ": value out of range");
11751175
}
11761176
return nChange;
11771177
}
@@ -1200,7 +1200,7 @@ CPubKey CWallet::GenerateNewHDMasterKey()
12001200

12011201
// write the key&metadata to the database
12021202
if (!AddKeyPubKey(key, pubkey))
1203-
throw std::runtime_error(std::string(__func__)+": AddKeyPubKey failed");
1203+
throw std::runtime_error(std::string(__func__) + ": AddKeyPubKey failed");
12041204
}
12051205

12061206
return pubkey;
@@ -1227,7 +1227,7 @@ bool CWallet::SetHDChain(const CHDChain& chain, bool memonly)
12271227
{
12281228
LOCK(cs_wallet);
12291229
if (!memonly && !CWalletDB(strWalletFile).WriteHDChain(chain))
1230-
throw runtime_error("AddHDChain(): writing chain failed");
1230+
throw runtime_error(std::string(__func__) + ": writing chain failed");
12311231

12321232
hdChain = chain;
12331233
return true;
@@ -2706,7 +2706,7 @@ bool CWallet::TopUpKeyPool(unsigned int kpSize)
27062706
if (!setKeyPool.empty())
27072707
nEnd = *(--setKeyPool.end()) + 1;
27082708
if (!walletdb.WritePool(nEnd, CKeyPool(GenerateNewKey())))
2709-
throw runtime_error("TopUpKeyPool(): writing generated key failed");
2709+
throw runtime_error(std::string(__func__) + ": writing generated key failed");
27102710
setKeyPool.insert(nEnd);
27112711
LogPrintf("keypool added key %d, size=%u\n", nEnd, setKeyPool.size());
27122712
}
@@ -2733,9 +2733,9 @@ void CWallet::ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool)
27332733
nIndex = *(setKeyPool.begin());
27342734
setKeyPool.erase(setKeyPool.begin());
27352735
if (!walletdb.ReadPool(nIndex, keypool))
2736-
throw runtime_error("ReserveKeyFromKeyPool(): read failed");
2736+
throw runtime_error(std::string(__func__) + ": read failed");
27372737
if (!HaveKey(keypool.vchPubKey.GetID()))
2738-
throw runtime_error("ReserveKeyFromKeyPool(): unknown key in key pool");
2738+
throw runtime_error(std::string(__func__) + ": unknown key in key pool");
27392739
assert(keypool.vchPubKey.IsValid());
27402740
LogPrintf("keypool reserve %d\n", nIndex);
27412741
}
@@ -2794,7 +2794,7 @@ int64_t CWallet::GetOldestKeyPoolTime()
27942794
CWalletDB walletdb(strWalletFile);
27952795
int64_t nIndex = *(setKeyPool.begin());
27962796
if (!walletdb.ReadPool(nIndex, keypool))
2797-
throw runtime_error("GetOldestKeyPoolTime(): read oldest key in keypool failed");
2797+
throw runtime_error(std::string(__func__) + ": read oldest key in keypool failed");
27982798
assert(keypool.vchPubKey.IsValid());
27992799
return keypool.nTime;
28002800
}
@@ -3021,11 +3021,11 @@ void CWallet::GetAllReserveKeys(set<CKeyID>& setAddress) const
30213021
{
30223022
CKeyPool keypool;
30233023
if (!walletdb.ReadPool(id, keypool))
3024-
throw runtime_error("GetAllReserveKeyHashes(): read failed");
3024+
throw runtime_error(std::string(__func__) + ": read failed");
30253025
assert(keypool.vchPubKey.IsValid());
30263026
CKeyID keyID = keypool.vchPubKey.GetID();
30273027
if (!HaveKey(keyID))
3028-
throw runtime_error("GetAllReserveKeyHashes(): unknown key in key pool");
3028+
throw runtime_error(std::string(__func__) + ": unknown key in key pool");
30293029
setAddress.insert(keyID);
30303030
}
30313031
}
@@ -3325,7 +3325,7 @@ bool CWallet::InitLoadWallet()
33253325
// generate a new master key
33263326
CPubKey masterPubKey = walletInstance->GenerateNewHDMasterKey();
33273327
if (!walletInstance->SetHDMasterKey(masterPubKey))
3328-
throw std::runtime_error("CWallet::GenerateNewKey(): Storing master key failed");
3328+
throw std::runtime_error(std::string(__func__) + ": Storing master key failed");
33293329
}
33303330
CPubKey newDefaultKey;
33313331
if (walletInstance->GetKeyFromPool(newDefaultKey)) {

src/wallet/walletdb.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
215215

216216
Dbc* pcursor = GetCursor();
217217
if (!pcursor)
218-
throw runtime_error("CWalletDB::ListAccountCreditDebit(): cannot create DB cursor");
218+
throw runtime_error(std::string(__func__) + ": cannot create DB cursor");
219219
unsigned int fFlags = DB_SET_RANGE;
220220
while (true)
221221
{
@@ -231,7 +231,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
231231
else if (ret != 0)
232232
{
233233
pcursor->close();
234-
throw runtime_error("CWalletDB::ListAccountCreditDebit(): error scanning DB");
234+
throw runtime_error(std::string(__func__) + ": error scanning DB");
235235
}
236236

237237
// Unserialize

0 commit comments

Comments
 (0)