Merge pull request #5438

27df412 make all catch() arguments const (Philip Kaufmann)
This commit is contained in:
Wladimir J. van der Laan 2014-12-17 17:34:20 +01:00
commit 89802fe3ee
No known key found for this signature in database
GPG key ID: 74810B012346C9A6
24 changed files with 78 additions and 82 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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 ? // TODO: detect EV certificates and set merchant = business name instead of unfriendly NID_commonName ?
} }
catch (SSLVerifyError& err) catch (const SSLVerifyError& err) {
{
fResult = false; fResult = false;
qWarning() << "PaymentRequestPlus::getMerchant : SSL error: " << err.what(); qWarning() << "PaymentRequestPlus::getMerchant : SSL error: " << err.what();
} }

View file

@ -180,7 +180,7 @@ void RPCExecutor::request(const QString &command)
emit reply(RPCConsole::CMD_REPLY, QString::fromStdString(strPrint)); 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 try // Nice formatting for standard-format error
{ {
@ -188,12 +188,12 @@ void RPCExecutor::request(const QString &command)
std::string message = find_value(objError, "message").get_str(); std::string message = find_value(objError, "message").get_str();
emit reply(RPCConsole::CMD_ERROR, QString::fromStdString(message) + " (code " + QString::number(code) + ")"); 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 { // Show raw JSON object
emit reply(RPCConsole::CMD_ERROR, QString::fromStdString(write_string(json_spirit::Value(objError), false))); 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())); emit reply(RPCConsole::CMD_ERROR, QString("Error: ") + QString::fromStdString(e.what()));
} }

View file

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

View file

@ -122,8 +122,7 @@ public:
tcp::resolver::query query(server.c_str(), port.c_str()); tcp::resolver::query query(server.c_str(), port.c_str());
endpoint_iterator = resolver.resolve(query); endpoint_iterator = resolver.resolve(query);
#if BOOST_VERSION >= 104300 #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) // 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()); tcp::resolver::query query(server.c_str(), port.c_str(), resolver_query_base::flags());
endpoint_iterator = resolver.resolve(query); endpoint_iterator = resolver.resolve(query);

View file

@ -174,7 +174,7 @@ string CRPCTable::help(string strCommand) const
if (setDone.insert(pfn).second) if (setDone.insert(pfn).second)
(*pfn)(params, true); (*pfn)(params, true);
} }
catch (std::exception& e) catch (const std::exception& e)
{ {
// Help text is returned in an exception // Help text is returned in an exception
string strHelp = string(e.what()); string strHelp = string(e.what());
@ -676,7 +676,7 @@ void StartRPCThreads()
if(bBindAny && bindAddress == asio::ip::address_v6::any() && !v6_only_error) if(bBindAny && bindAddress == asio::ip::address_v6::any() && !v6_only_error)
break; 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()); 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()); 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)
Value result = tableRPC.execute(jreq.strMethod, jreq.params); Value result = tableRPC.execute(jreq.strMethod, jreq.params);
rpc_result = JSONRPCReplyObj(result, Value::null, jreq.id); rpc_result = JSONRPCReplyObj(result, Value::null, jreq.id);
} }
catch (Object& objError) catch (const Object& objError)
{ {
rpc_result = JSONRPCReplyObj(Value::null, objError, jreq.id); rpc_result = JSONRPCReplyObj(Value::null, objError, jreq.id);
} }
catch (std::exception& e) catch (const std::exception& e)
{ {
rpc_result = JSONRPCReplyObj(Value::null, rpc_result = JSONRPCReplyObj(Value::null,
JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq.id); JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq.id);
@ -922,12 +922,12 @@ static bool HTTPReq_JSONRPC(AcceptedConnection *conn,
conn->stream() << HTTPReplyHeader(HTTP_OK, fRun, strReply.size()) << strReply << std::flush; conn->stream() << HTTPReplyHeader(HTTP_OK, fRun, strReply.size()) << strReply << std::flush;
} }
catch (Object& objError) catch (const Object& objError)
{ {
ErrorReply(conn->stream(), objError, jreq.id); ErrorReply(conn->stream(), objError, jreq.id);
return false; return false;
} }
catch (std::exception& e) catch (const std::exception& e)
{ {
ErrorReply(conn->stream(), JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq.id); ErrorReply(conn->stream(), JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq.id);
return false; return false;
@ -1013,7 +1013,7 @@ json_spirit::Value CRPCTable::execute(const std::string &strMethod, const json_s
} }
return result; return result;
} }
catch (std::exception& e) catch (const std::exception& e)
{ {
throw JSONRPCError(RPC_MISC_ERROR, e.what()); throw JSONRPCError(RPC_MISC_ERROR, e.what());
} }

View file

@ -79,7 +79,7 @@ int bitcoinconsensus_verify_script(const unsigned char *scriptPubKey, unsigned i
set_error(err, bitcoinconsensus_ERR_OK); set_error(err, bitcoinconsensus_ERR_OK);
return VerifyScript(tx.vin[nIn].scriptSig, CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen), flags, SignatureChecker(tx, nIn), NULL); 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 return set_error(err, bitcoinconsensus_ERR_TX_DESERIALIZE); // Error deserializing
} }
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -664,7 +664,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
} }
pcursor->close(); pcursor->close();
} }
catch (boost::thread_interrupted) { catch (const boost::thread_interrupted&) {
throw; throw;
} }
catch (...) { catch (...) {
@ -757,7 +757,7 @@ DBErrors CWalletDB::FindWalletTx(CWallet* pwallet, vector<uint256>& vTxHash, vec
} }
pcursor->close(); pcursor->close();
} }
catch (boost::thread_interrupted) { catch (const boost::thread_interrupted&) {
throw; throw;
} }
catch (...) { catch (...) {