Browse Source

Show error message if ReadConfigFile fails

A runaway exception was raised if ReadConfigFile fails (usually
due to a parse error in bitcoin.conf). Show an error message instead.

Fixes #4013.
0.10
Wladimir J. van der Laan 11 years ago
parent
commit
4ae5e72128
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 5
      src/bitcoin-cli.cpp
  2. 6
      src/bitcoind.cpp
  3. 6
      src/qt/bitcoin.cpp

5
src/bitcoin-cli.cpp

@ -27,7 +27,12 @@ static bool AppInitRPC(int argc, char* argv[]) @@ -27,7 +27,12 @@ static bool AppInitRPC(int argc, char* argv[])
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", mapArgs["-datadir"].c_str());
return false;
}
try {
ReadConfigFile(mapArgs, mapMultiArgs);
} catch(std::exception &e) {
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
return false;
}
// Check for -testnet or -regtest parameter (TestNet() calls are only valid after this clause)
if (!SelectParamsFromCommandLine()) {
fprintf(stderr, "Error: Invalid combination of -regtest and -testnet.\n");

6
src/bitcoind.cpp

@ -70,7 +70,13 @@ bool AppInit(int argc, char* argv[]) @@ -70,7 +70,13 @@ bool AppInit(int argc, char* argv[])
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", mapArgs["-datadir"].c_str());
return false;
}
try
{
ReadConfigFile(mapArgs, mapMultiArgs);
} catch(std::exception &e) {
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
return false;
}
// Check for -testnet or -regtest parameter (TestNet() calls are only valid after this clause)
if (!SelectParamsFromCommandLine()) {
fprintf(stderr, "Error: Invalid combination of -regtest and -testnet.\n");

6
src/qt/bitcoin.cpp

@ -507,7 +507,13 @@ int main(int argc, char *argv[]) @@ -507,7 +507,13 @@ int main(int argc, char *argv[])
QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(mapArgs["-datadir"])));
return 1;
}
try {
ReadConfigFile(mapArgs, mapMultiArgs);
} catch(std::exception &e) {
QMessageBox::critical(0, QObject::tr("Bitcoin"),
QObject::tr("Error: Cannot parse configuration file: %1. Only use key=value syntax.").arg(e.what()));
return false;
}
/// 7. Determine network (and switch to network specific options)
// - Do not call Params() before this step

Loading…
Cancel
Save