Browse Source

make all catch() arguments const

- I saw this on http://en.cppreference.com/w/cpp/language/try_catch and
  thought it would be a good idea
- also unify used format to better be able to search for exception
  uses in our codebase
0.13
Philip Kaufmann 10 years ago
parent
commit
27df4123c4
  1. 12
      src/bitcoin-cli.cpp
  2. 8
      src/bitcoin-tx.cpp
  3. 4
      src/bitcoind.cpp
  4. 4
      src/core_read.cpp
  5. 6
      src/init.cpp
  6. 24
      src/main.cpp
  7. 2
      src/miner.cpp
  8. 10
      src/net.cpp
  9. 12
      src/qt/bitcoin.cpp
  10. 4
      src/qt/intro.cpp
  11. 3
      src/qt/paymentrequestplus.cpp
  12. 6
      src/qt/rpcconsole.cpp
  13. 2
      src/rest.cpp
  14. 3
      src/rpcprotocol.h
  15. 2
      src/rpcrawtransaction.cpp
  16. 16
      src/rpcserver.cpp
  17. 2
      src/script/bitcoinconsensus.cpp
  18. 2
      src/test/alert_tests.cpp
  19. 3
      src/test/rpc_tests.cpp
  20. 4
      src/txdb.cpp
  21. 4
      src/txmempool.cpp
  22. 9
      src/util.cpp
  23. 10
      src/util.h
  24. 8
      src/walletdb.cpp

12
src/bitcoin-cli.cpp

@ -86,7 +86,7 @@ static bool AppInitRPC(int argc, char* argv[]) @@ -86,7 +86,7 @@ static bool AppInitRPC(int argc, char* argv[])
}
try {
ReadConfigFile(mapArgs, mapMultiArgs);
} catch(std::exception &e) {
} catch (const std::exception& e) {
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
return false;
}
@ -206,7 +206,7 @@ int CommandLineRPC(int argc, char *argv[]) @@ -206,7 +206,7 @@ int CommandLineRPC(int argc, char *argv[])
// Connection succeeded, no need to retry.
break;
}
catch (const CConnectionFailed& e) {
catch (const CConnectionFailed&) {
if (fWait)
MilliSleep(1000);
else
@ -214,10 +214,10 @@ int CommandLineRPC(int argc, char *argv[]) @@ -214,10 +214,10 @@ int CommandLineRPC(int argc, char *argv[])
}
} while (fWait);
}
catch (boost::thread_interrupted) {
catch (const boost::thread_interrupted&) {
throw;
}
catch (std::exception& e) {
catch (const std::exception& e) {
strPrint = string("error: ") + e.what();
nRet = EXIT_FAILURE;
}
@ -240,7 +240,7 @@ int main(int argc, char* argv[]) @@ -240,7 +240,7 @@ int main(int argc, char* argv[])
if(!AppInitRPC(argc, argv))
return EXIT_FAILURE;
}
catch (std::exception& e) {
catch (const std::exception& e) {
PrintExceptionContinue(&e, "AppInitRPC()");
return EXIT_FAILURE;
} catch (...) {
@ -252,7 +252,7 @@ int main(int argc, char* argv[]) @@ -252,7 +252,7 @@ int main(int argc, char* argv[])
try {
ret = CommandLineRPC(argc, argv);
}
catch (std::exception& e) {
catch (const std::exception& e) {
PrintExceptionContinue(&e, "CommandLineRPC()");
} catch (...) {
PrintExceptionContinue(NULL, "CommandLineRPC()");

8
src/bitcoin-tx.cpp

@ -586,10 +586,10 @@ static int CommandLineRawTx(int argc, char* argv[]) @@ -586,10 +586,10 @@ static int CommandLineRawTx(int argc, char* argv[])
OutputTx(tx);
}
catch (boost::thread_interrupted) {
catch (const boost::thread_interrupted&) {
throw;
}
catch (std::exception& e) {
catch (const std::exception& e) {
strPrint = string("error: ") + e.what();
nRet = EXIT_FAILURE;
}
@ -612,7 +612,7 @@ int main(int argc, char* argv[]) @@ -612,7 +612,7 @@ int main(int argc, char* argv[])
if(!AppInitRawTx(argc, argv))
return EXIT_FAILURE;
}
catch (std::exception& e) {
catch (const std::exception& e) {
PrintExceptionContinue(&e, "AppInitRawTx()");
return EXIT_FAILURE;
} catch (...) {
@ -624,7 +624,7 @@ int main(int argc, char* argv[]) @@ -624,7 +624,7 @@ int main(int argc, char* argv[])
try {
ret = CommandLineRawTx(argc, argv);
}
catch (std::exception& e) {
catch (const std::exception& e) {
PrintExceptionContinue(&e, "CommandLineRawTx()");
} catch (...) {
PrintExceptionContinue(NULL, "CommandLineRawTx()");

4
src/bitcoind.cpp

@ -97,7 +97,7 @@ bool AppInit(int argc, char* argv[]) @@ -97,7 +97,7 @@ bool AppInit(int argc, char* argv[])
try
{
ReadConfigFile(mapArgs, mapMultiArgs);
} catch(std::exception &e) {
} catch (const std::exception& e) {
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
return false;
}
@ -147,7 +147,7 @@ bool AppInit(int argc, char* argv[]) @@ -147,7 +147,7 @@ bool AppInit(int argc, char* argv[])
detectShutdownThread = new boost::thread(boost::bind(&DetectShutdownThread, &threadGroup));
fRet = AppInit2(threadGroup);
}
catch (std::exception& e) {
catch (const std::exception& e) {
PrintExceptionContinue(&e, "AppInit()");
} catch (...) {
PrintExceptionContinue(NULL, "AppInit()");

4
src/core_read.cpp

@ -102,7 +102,7 @@ bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx) @@ -102,7 +102,7 @@ bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx)
try {
ssData >> tx;
}
catch (const std::exception &) {
catch (const std::exception&) {
return false;
}
@ -119,7 +119,7 @@ bool DecodeHexBlk(CBlock& block, const std::string& strHexBlk) @@ -119,7 +119,7 @@ bool DecodeHexBlk(CBlock& block, const std::string& strHexBlk)
try {
ssBlock >> block;
}
catch (const std::exception &) {
catch (const std::exception&) {
return false;
}

6
src/init.cpp

@ -778,7 +778,7 @@ bool AppInit2(boost::thread_group& threadGroup) @@ -778,7 +778,7 @@ bool AppInit2(boost::thread_group& threadGroup)
try {
boost::filesystem::rename(pathDatabase, pathDatabaseBak);
LogPrintf("Moved old %s to %s. Retrying.\n", pathDatabase.string(), pathDatabaseBak.string());
} catch(boost::filesystem::filesystem_error &error) {
} catch (const boost::filesystem::filesystem_error&) {
// failure is ok (well, not really, but it's not worse than what we started with)
}
@ -931,7 +931,7 @@ bool AppInit2(boost::thread_group& threadGroup) @@ -931,7 +931,7 @@ bool AppInit2(boost::thread_group& threadGroup)
filesystem::create_hard_link(source, dest);
LogPrintf("Hardlinked %s -> %s\n", source.string(), dest.string());
linked = true;
} catch (filesystem::filesystem_error & e) {
} catch (const filesystem::filesystem_error& e) {
// Note: hardlink creation failing is not a disaster, it just means
// blocks will get re-downloaded from peers.
LogPrintf("Error hardlinking blk%04u.dat : %s\n", i, e.what());
@ -1008,7 +1008,7 @@ bool AppInit2(boost::thread_group& threadGroup) @@ -1008,7 +1008,7 @@ bool AppInit2(boost::thread_group& threadGroup)
strLoadError = _("Corrupted block database detected");
break;
}
} catch(std::exception &e) {
} catch (const std::exception& e) {
if (fDebug) LogPrintf("%s\n", e.what());
strLoadError = _("Error opening block database");
break;

24
src/main.cpp

@ -1091,7 +1091,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock @@ -1091,7 +1091,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
file >> header;
fseek(file.Get(), postx.nTxOffset, SEEK_CUR);
file >> txOut;
} catch (std::exception &e) {
} catch (const std::exception& e) {
return error("%s : Deserialize or I/O error - %s", __func__, e.what());
}
hashBlock = header.GetHash();
@ -1174,7 +1174,7 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos) @@ -1174,7 +1174,7 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos)
try {
filein >> block;
}
catch (std::exception &e) {
catch (const std::exception& e) {
return error("%s : Deserialize or I/O error - %s", __func__, e.what());
}
@ -2598,7 +2598,7 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex, @@ -2598,7 +2598,7 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex,
return state.Abort("Failed to write block");
if (!ReceivedBlockTransactions(block, state, pindex, blockPos))
return error("AcceptBlock() : ReceivedBlockTransactions failed");
} catch(std::runtime_error &e) {
} catch (const std::runtime_error& e) {
return state.Abort(std::string("System error: ") + e.what());
}
@ -2990,7 +2990,7 @@ bool InitBlockIndex() { @@ -2990,7 +2990,7 @@ bool InitBlockIndex() {
return error("LoadBlockIndex() : genesis block cannot be activated");
// Force a chainstate write so that when we VerifyDB in a moment, it doesn't check stale data
return FlushStateToDisk(state, FLUSH_STATE_ALWAYS);
} catch(std::runtime_error &e) {
} catch (const std::runtime_error& e) {
return error("LoadBlockIndex() : failed to initialize block database: %s", e.what());
}
}
@ -3030,7 +3030,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp) @@ -3030,7 +3030,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
blkdat >> nSize;
if (nSize < 80 || nSize > MAX_BLOCK_SIZE)
continue;
} catch (const std::exception &) {
} catch (const std::exception&) {
// no valid block header found; don't complain
break;
}
@ -3090,11 +3090,11 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp) @@ -3090,11 +3090,11 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
mapBlocksUnknownParent.erase(it);
}
}
} catch (std::exception &e) {
} catch (const std::exception& e) {
LogPrintf("%s : Deserialize or I/O error - %s", __func__, e.what());
}
}
} catch(std::runtime_error &e) {
} catch (const std::runtime_error& e) {
AbortNode(std::string("System error: ") + e.what());
}
if (nLoaded > 0)
@ -4088,7 +4088,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, @@ -4088,7 +4088,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
ss << ": hash " << hash.ToString();
}
LogPrint("net", "Reject %s\n", SanitizeString(ss.str()));
} catch (std::ios_base::failure& e) {
} catch (const std::ios_base::failure&) {
// Avoid feedback loops by preventing reject messages from triggering a new reject message.
LogPrint("net", "Unparseable reject message received\n");
}
@ -4192,7 +4192,7 @@ bool ProcessMessages(CNode* pfrom) @@ -4192,7 +4192,7 @@ bool ProcessMessages(CNode* pfrom)
fRet = ProcessMessage(pfrom, strCommand, vRecv, msg.nTime);
boost::this_thread::interruption_point();
}
catch (std::ios_base::failure& e)
catch (const std::ios_base::failure& e)
{
pfrom->PushMessage("reject", strCommand, REJECT_MALFORMED, string("error parsing message"));
if (strstr(e.what(), "end of data"))
@ -4210,10 +4210,10 @@ bool ProcessMessages(CNode* pfrom) @@ -4210,10 +4210,10 @@ bool ProcessMessages(CNode* pfrom)
PrintExceptionContinue(&e, "ProcessMessages()");
}
}
catch (boost::thread_interrupted) {
catch (const boost::thread_interrupted&) {
throw;
}
catch (std::exception& e) {
catch (const std::exception& e) {
PrintExceptionContinue(&e, "ProcessMessages()");
} catch (...) {
PrintExceptionContinue(NULL, "ProcessMessages()");
@ -4507,7 +4507,7 @@ bool CBlockUndo::ReadFromDisk(const CDiskBlockPos &pos, const uint256 &hashBlock @@ -4507,7 +4507,7 @@ bool CBlockUndo::ReadFromDisk(const CDiskBlockPos &pos, const uint256 &hashBlock
filein >> *this;
filein >> hashChecksum;
}
catch (std::exception &e) {
catch (const std::exception& e) {
return error("%s : Deserialize or I/O error - %s", __func__, e.what());
}

2
src/miner.cpp

@ -565,7 +565,7 @@ void static BitcoinMiner(CWallet *pwallet) @@ -565,7 +565,7 @@ void static BitcoinMiner(CWallet *pwallet)
}
}
}
catch (boost::thread_interrupted)
catch (const boost::thread_interrupted&)
{
LogPrintf("BitcoinMiner terminated\n");
throw;

10
src/net.cpp

@ -601,7 +601,7 @@ int CNetMessage::readHeader(const char *pch, unsigned int nBytes) @@ -601,7 +601,7 @@ int CNetMessage::readHeader(const char *pch, unsigned int nBytes)
try {
hdrbuf >> hdr;
}
catch (const std::exception &) {
catch (const std::exception&) {
return -1;
}
@ -1068,7 +1068,7 @@ void ThreadMapPort() @@ -1068,7 +1068,7 @@ void ThreadMapPort()
MilliSleep(20*60*1000); // Refresh every 20 minutes
}
}
catch (boost::thread_interrupted)
catch (const boost::thread_interrupted&)
{
r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", 0);
LogPrintf("UPNP_DeletePortMapping() returned : %d\n", r);
@ -1854,7 +1854,7 @@ bool CAddrDB::Write(const CAddrMan& addr) @@ -1854,7 +1854,7 @@ bool CAddrDB::Write(const CAddrMan& addr)
try {
fileout << ssPeers;
}
catch (std::exception &e) {
catch (const std::exception& e) {
return error("%s : Serialize or I/O error - %s", __func__, e.what());
}
FileCommit(fileout.Get());
@ -1890,7 +1890,7 @@ bool CAddrDB::Read(CAddrMan& addr) @@ -1890,7 +1890,7 @@ bool CAddrDB::Read(CAddrMan& addr)
filein.read((char *)&vchData[0], dataSize);
filein >> hashIn;
}
catch (std::exception &e) {
catch (const std::exception& e) {
return error("%s : Deserialize or I/O error - %s", __func__, e.what());
}
filein.fclose();
@ -1914,7 +1914,7 @@ bool CAddrDB::Read(CAddrMan& addr) @@ -1914,7 +1914,7 @@ bool CAddrDB::Read(CAddrMan& addr)
// de-serialize address data into one CAddrMan object
ssPeers >> addr;
}
catch (std::exception &e) {
catch (const std::exception& e) {
return error("%s : Deserialize or I/O error - %s", __func__, e.what());
}

12
src/qt/bitcoin.cpp

@ -173,7 +173,7 @@ private: @@ -173,7 +173,7 @@ private:
boost::thread_group threadGroup;
/// Pass fatal exception message to UI thread
void handleRunawayException(std::exception *e);
void handleRunawayException(const std::exception *e);
};
/** Main Bitcoin application object */
@ -240,7 +240,7 @@ BitcoinCore::BitcoinCore(): @@ -240,7 +240,7 @@ BitcoinCore::BitcoinCore():
{
}
void BitcoinCore::handleRunawayException(std::exception *e)
void BitcoinCore::handleRunawayException(const std::exception *e)
{
PrintExceptionContinue(e, "Runaway exception");
emit runawayException(QString::fromStdString(strMiscWarning));
@ -260,7 +260,7 @@ void BitcoinCore::initialize() @@ -260,7 +260,7 @@ void BitcoinCore::initialize()
StartDummyRPCThread();
}
emit initializeResult(rv);
} catch (std::exception& e) {
} catch (const std::exception& e) {
handleRunawayException(&e);
} catch (...) {
handleRunawayException(NULL);
@ -277,7 +277,7 @@ void BitcoinCore::shutdown() @@ -277,7 +277,7 @@ void BitcoinCore::shutdown()
Shutdown();
qDebug() << __func__ << ": Shutdown finished";
emit shutdownResult(1);
} catch (std::exception& e) {
} catch (const std::exception& e) {
handleRunawayException(&e);
} catch (...) {
handleRunawayException(NULL);
@ -551,7 +551,7 @@ int main(int argc, char *argv[]) @@ -551,7 +551,7 @@ int main(int argc, char *argv[])
}
try {
ReadConfigFile(mapArgs, mapMultiArgs);
} catch(std::exception &e) {
} catch (const std::exception& e) {
QMessageBox::critical(0, QObject::tr("Bitcoin Core"),
QObject::tr("Error: Cannot parse configuration file: %1. Only use key=value syntax.").arg(e.what()));
return false;
@ -628,7 +628,7 @@ int main(int argc, char *argv[]) @@ -628,7 +628,7 @@ int main(int argc, char *argv[])
app.exec();
app.requestShutdown();
app.exec();
} catch (std::exception& e) {
} catch (const std::exception& e) {
PrintExceptionContinue(&e, "Runaway exception");
app.handleRunawayException(QString::fromStdString(strMiscWarning));
} catch (...) {

4
src/qt/intro.cpp

@ -95,7 +95,7 @@ void FreespaceChecker::check() @@ -95,7 +95,7 @@ void FreespaceChecker::check()
replyMessage = tr("Path already exists, and is not a directory.");
}
}
} catch(fs::filesystem_error &e)
} catch (const fs::filesystem_error&)
{
/* Parent directory does not exist or is not accessible */
replyStatus = ST_ERROR;
@ -180,7 +180,7 @@ void Intro::pickDataDirectory() @@ -180,7 +180,7 @@ void Intro::pickDataDirectory()
try {
TryCreateDirectory(GUIUtil::qstringToBoostPath(dataDir));
break;
} catch(fs::filesystem_error &e) {
} catch (const fs::filesystem_error&) {
QMessageBox::critical(0, tr("Bitcoin Core"),
tr("Error: Specified data directory \"%1\" cannot be created.").arg(dataDir));
/* fall through, back to choosing screen */

3
src/qt/paymentrequestplus.cpp

@ -181,8 +181,7 @@ bool PaymentRequestPlus::getMerchant(X509_STORE* certStore, QString& merchant) c @@ -181,8 +181,7 @@ bool PaymentRequestPlus::getMerchant(X509_STORE* certStore, QString& merchant) c
}
// TODO: detect EV certificates and set merchant = business name instead of unfriendly NID_commonName ?
}
catch (SSLVerifyError& err)
{
catch (const SSLVerifyError& err) {
fResult = false;
qWarning() << "PaymentRequestPlus::getMerchant : SSL error: " << err.what();
}

6
src/qt/rpcconsole.cpp

@ -180,7 +180,7 @@ void RPCExecutor::request(const QString &command) @@ -180,7 +180,7 @@ void RPCExecutor::request(const QString &command)
emit reply(RPCConsole::CMD_REPLY, QString::fromStdString(strPrint));
}
catch (json_spirit::Object& objError)
catch (const json_spirit::Object& objError)
{
try // Nice formatting for standard-format error
{
@ -188,12 +188,12 @@ void RPCExecutor::request(const QString &command) @@ -188,12 +188,12 @@ void RPCExecutor::request(const QString &command)
std::string message = find_value(objError, "message").get_str();
emit reply(RPCConsole::CMD_ERROR, QString::fromStdString(message) + " (code " + QString::number(code) + ")");
}
catch(std::runtime_error &) // raised when converting to invalid type, i.e. missing code or message
catch (const std::runtime_error&) // raised when converting to invalid type, i.e. missing code or message
{ // Show raw JSON object
emit reply(RPCConsole::CMD_ERROR, QString::fromStdString(write_string(json_spirit::Value(objError), false)));
}
}
catch (std::exception& e)
catch (const std::exception& e)
{
emit reply(RPCConsole::CMD_ERROR, QString("Error: ") + QString::fromStdString(e.what()));
}

2
src/rest.cpp

@ -307,7 +307,7 @@ bool HTTPReq_REST(AcceptedConnection* conn, @@ -307,7 +307,7 @@ bool HTTPReq_REST(AcceptedConnection* conn,
return uri_prefixes[i].handler(conn, strReq, mapHeaders, fRun);
}
}
} catch (RestErr& re) {
} catch (const RestErr& re) {
conn->stream() << HTTPReply(re.status, re.message + "\r\n", false, false, "text/plain") << std::flush;
return false;
}

3
src/rpcprotocol.h

@ -122,8 +122,7 @@ public: @@ -122,8 +122,7 @@ public:
tcp::resolver::query query(server.c_str(), port.c_str());
endpoint_iterator = resolver.resolve(query);
#if BOOST_VERSION >= 104300
} catch(boost::system::system_error &e)
{
} catch (const boost::system::system_error&) {
// If we at first don't succeed, try blanket lookup (IPv4+IPv6 independent of configured interfaces)
tcp::resolver::query query(server.c_str(), port.c_str(), resolver_query_base::flags());
endpoint_iterator = resolver.resolve(query);

2
src/rpcrawtransaction.cpp

@ -545,7 +545,7 @@ Value signrawtransaction(const Array& params, bool fHelp) @@ -545,7 +545,7 @@ Value signrawtransaction(const Array& params, bool fHelp)
ssData >> tx;
txVariants.push_back(tx);
}
catch (const std::exception &) {
catch (const std::exception&) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
}
}

16
src/rpcserver.cpp

@ -174,7 +174,7 @@ string CRPCTable::help(string strCommand) const @@ -174,7 +174,7 @@ string CRPCTable::help(string strCommand) const
if (setDone.insert(pfn).second)
(*pfn)(params, true);
}
catch (std::exception& e)
catch (const std::exception& e)
{
// Help text is returned in an exception
string strHelp = string(e.what());
@ -631,7 +631,7 @@ void StartRPCThreads() @@ -631,7 +631,7 @@ void StartRPCThreads()
try {
vEndpoints.push_back(ParseEndpoint(addr, defaultPort));
}
catch(const boost::system::system_error &)
catch (const boost::system::system_error&)
{
uiInterface.ThreadSafeMessageBox(
strprintf(_("Could not parse -rpcbind value %s as network address"), addr),
@ -676,7 +676,7 @@ void StartRPCThreads() @@ -676,7 +676,7 @@ void StartRPCThreads()
if(bBindAny && bindAddress == asio::ip::address_v6::any() && !v6_only_error)
break;
}
catch(boost::system::system_error &e)
catch (const boost::system::system_error& e)
{
LogPrintf("ERROR: Binding RPC on address %s port %i failed: %s\n", bindAddress.to_string(), endpoint.port(), e.what());
strerr = strprintf(_("An error occurred while setting up the RPC address %s port %u for listening: %s"), bindAddress.to_string(), endpoint.port(), e.what());
@ -842,11 +842,11 @@ static Object JSONRPCExecOne(const Value& req) @@ -842,11 +842,11 @@ static Object JSONRPCExecOne(const Value& req)
Value result = tableRPC.execute(jreq.strMethod, jreq.params);
rpc_result = JSONRPCReplyObj(result, Value::null, jreq.id);
}
catch (Object& objError)
catch (const Object& objError)
{
rpc_result = JSONRPCReplyObj(Value::null, objError, jreq.id);
}
catch (std::exception& e)
catch (const std::exception& e)
{
rpc_result = JSONRPCReplyObj(Value::null,
JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq.id);
@ -922,12 +922,12 @@ static bool HTTPReq_JSONRPC(AcceptedConnection *conn, @@ -922,12 +922,12 @@ static bool HTTPReq_JSONRPC(AcceptedConnection *conn,
conn->stream() << HTTPReplyHeader(HTTP_OK, fRun, strReply.size()) << strReply << std::flush;
}
catch (Object& objError)
catch (const Object& objError)
{
ErrorReply(conn->stream(), objError, jreq.id);
return false;
}
catch (std::exception& e)
catch (const std::exception& e)
{
ErrorReply(conn->stream(), JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq.id);
return false;
@ -1013,7 +1013,7 @@ json_spirit::Value CRPCTable::execute(const std::string &strMethod, const json_s @@ -1013,7 +1013,7 @@ json_spirit::Value CRPCTable::execute(const std::string &strMethod, const json_s
}
return result;
}
catch (std::exception& e)
catch (const std::exception& e)
{
throw JSONRPCError(RPC_MISC_ERROR, e.what());
}

2
src/script/bitcoinconsensus.cpp

@ -79,7 +79,7 @@ int bitcoinconsensus_verify_script(const unsigned char *scriptPubKey, unsigned i @@ -79,7 +79,7 @@ int bitcoinconsensus_verify_script(const unsigned char *scriptPubKey, unsigned i
set_error(err, bitcoinconsensus_ERR_OK);
return VerifyScript(tx.vin[nIn].scriptSig, CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen), flags, SignatureChecker(tx, nIn), NULL);
} catch (std::exception &e) {
} catch (const std::exception&) {
return set_error(err, bitcoinconsensus_ERR_TX_DESERIALIZE); // Error deserializing
}
}

2
src/test/alert_tests.cpp

@ -92,7 +92,7 @@ struct ReadAlerts @@ -92,7 +92,7 @@ struct ReadAlerts
alerts.push_back(alert);
}
}
catch (std::exception) { }
catch (const std::exception&) { }
}
~ReadAlerts() { }

3
src/test/rpc_tests.cpp

@ -39,8 +39,7 @@ Value CallRPC(string args) @@ -39,8 +39,7 @@ Value CallRPC(string args)
Value result = (*method)(params, false);
return result;
}
catch (Object& objError)
{
catch (const Object& objError) {
throw runtime_error(find_value(objError, "message").get_str());
}
}

4
src/txdb.cpp

@ -129,7 +129,7 @@ bool CCoinsViewDB::GetStats(CCoinsStats &stats) const { @@ -129,7 +129,7 @@ bool CCoinsViewDB::GetStats(CCoinsStats &stats) const {
ss << VARINT(0);
}
pcursor->Next();
} catch (std::exception &e) {
} catch (const std::exception& e) {
return error("%s : Deserialize or I/O error - %s", __func__, e.what());
}
}
@ -218,7 +218,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts() @@ -218,7 +218,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
} else {
break; // if shutdown requested or finished loading block index
}
} catch (std::exception &e) {
} catch (const std::exception& e) {
return error("%s : Deserialize or I/O error - %s", __func__, e.what());
}
}

4
src/txmempool.cpp

@ -648,7 +648,7 @@ CTxMemPool::WriteFeeEstimates(CAutoFile& fileout) const @@ -648,7 +648,7 @@ CTxMemPool::WriteFeeEstimates(CAutoFile& fileout) const
fileout << CLIENT_VERSION; // version that wrote the file
minerPolicyEstimator->Write(fileout);
}
catch (const std::exception &) {
catch (const std::exception&) {
LogPrintf("CTxMemPool::WriteFeeEstimates() : unable to write policy estimator data (non-fatal)");
return false;
}
@ -667,7 +667,7 @@ CTxMemPool::ReadFeeEstimates(CAutoFile& filein) @@ -667,7 +667,7 @@ CTxMemPool::ReadFeeEstimates(CAutoFile& filein)
LOCK(cs);
minerPolicyEstimator->Read(filein, minRelayFee);
}
catch (const std::exception &) {
catch (const std::exception&) {
LogPrintf("CTxMemPool::ReadFeeEstimates() : unable to read policy estimator data (non-fatal)");
return false;
}

9
src/util.cpp

@ -346,7 +346,7 @@ bool SoftSetBoolArg(const std::string& strArg, bool fValue) @@ -346,7 +346,7 @@ bool SoftSetBoolArg(const std::string& strArg, bool fValue)
return SoftSetArg(strArg, std::string("0"));
}
static std::string FormatException(std::exception* pex, const char* pszThread)
static std::string FormatException(const std::exception* pex, const char* pszThread)
{
#ifdef WIN32
char pszModule[MAX_PATH] = "";
@ -362,7 +362,7 @@ static std::string FormatException(std::exception* pex, const char* pszThread) @@ -362,7 +362,7 @@ static std::string FormatException(std::exception* pex, const char* pszThread)
"UNKNOWN EXCEPTION \n%s in %s \n", pszModule, pszThread);
}
void PrintExceptionContinue(std::exception* pex, const char* pszThread)
void PrintExceptionContinue(const std::exception* pex, const char* pszThread)
{
std::string message = FormatException(pex, pszThread);
LogPrintf("\n\n************************\n%s\n", message);
@ -514,7 +514,7 @@ bool TryCreateDirectory(const boost::filesystem::path& p) @@ -514,7 +514,7 @@ bool TryCreateDirectory(const boost::filesystem::path& p)
try
{
return boost::filesystem::create_directory(p);
} catch (boost::filesystem::filesystem_error) {
} catch (const boost::filesystem::filesystem_error&) {
if (!boost::filesystem::exists(p) || !boost::filesystem::is_directory(p))
throw;
}
@ -721,8 +721,7 @@ void SetupEnvironment() @@ -721,8 +721,7 @@ void SetupEnvironment()
#else // boost filesystem v2
std::locale(); // Raises runtime error if current locale is invalid
#endif
} catch(std::runtime_error &e)
{
} catch (const std::runtime_error&) {
setenv("LC_ALL", "C", 1); // Force C locale
}
#endif

10
src/util.h

@ -84,7 +84,7 @@ static inline bool error(const char* format) @@ -84,7 +84,7 @@ static inline bool error(const char* format)
return false;
}
void PrintExceptionContinue(std::exception* pex, const char* pszThread);
void PrintExceptionContinue(const std::exception *pex, const char* pszThread);
void ParseParameters(int argc, const char*const argv[]);
void FileCommit(FILE *fileout);
bool TruncateFile(FILE *file, unsigned int length);
@ -186,12 +186,12 @@ template <typename Callable> void LoopForever(const char* name, Callable func, @@ -186,12 +186,12 @@ template <typename Callable> void LoopForever(const char* name, Callable func,
func();
}
}
catch (boost::thread_interrupted)
catch (const boost::thread_interrupted&)
{
LogPrintf("%s thread stop\n", name);
throw;
}
catch (std::exception& e) {
catch (const std::exception& e) {
PrintExceptionContinue(&e, name);
throw;
}
@ -214,12 +214,12 @@ template <typename Callable> void TraceThread(const char* name, Callable func) @@ -214,12 +214,12 @@ template <typename Callable> void TraceThread(const char* name, Callable func)
func();
LogPrintf("%s thread exit\n", name);
}
catch (boost::thread_interrupted)
catch (const boost::thread_interrupted&)
{
LogPrintf("%s thread interrupt\n", name);
throw;
}
catch (std::exception& e) {
catch (const std::exception& e) {
PrintExceptionContinue(&e, name);
throw;
}

8
src/walletdb.cpp

@ -460,7 +460,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, @@ -460,7 +460,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
{
ssValue >> hash;
}
catch(...){}
catch (...) {}
bool fSkipCheck = false;
@ -664,7 +664,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) @@ -664,7 +664,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
}
pcursor->close();
}
catch (boost::thread_interrupted) {
catch (const boost::thread_interrupted&) {
throw;
}
catch (...) {
@ -757,7 +757,7 @@ DBErrors CWalletDB::FindWalletTx(CWallet* pwallet, vector<uint256>& vTxHash, vec @@ -757,7 +757,7 @@ DBErrors CWalletDB::FindWalletTx(CWallet* pwallet, vector<uint256>& vTxHash, vec
}
pcursor->close();
}
catch (boost::thread_interrupted) {
catch (const boost::thread_interrupted&) {
throw;
}
catch (...) {
@ -878,7 +878,7 @@ bool BackupWallet(const CWallet& wallet, const string& strDest) @@ -878,7 +878,7 @@ bool BackupWallet(const CWallet& wallet, const string& strDest)
#endif
LogPrintf("copied wallet.dat to %s\n", pathDest.string());
return true;
} catch(const filesystem::filesystem_error &e) {
} catch (const filesystem::filesystem_error& e) {
LogPrintf("error copying wallet.dat to %s - %s\n", pathDest.string(), e.what());
return false;
}

Loading…
Cancel
Save