Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Commit b35da15

Browse files
committed
Log json exception details on chain config error
Also return new error code AlethErrors::ConfigFileInvalid
1 parent ae042a3 commit b35da15

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

aleth/main.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#include <libweb3jsonrpc/Debug.h>
3939
#include <libweb3jsonrpc/Test.h>
4040

41+
#include <json_spirit/JsonSpiritHeaders.h>
42+
4143
#include "MinerAux.h"
4244
#include "AccountManager.h"
4345

@@ -49,6 +51,7 @@ using namespace dev::p2p;
4951
using namespace dev::eth;
5052
namespace po = boost::program_options;
5153
namespace fs = boost::filesystem;
54+
namespace js = json_spirit;
5255

5356
namespace
5457
{
@@ -680,16 +683,27 @@ int main(int argc, char** argv)
680683

681684
if (!configJSON.empty())
682685
{
686+
bool chainConfigError = true;
683687
try
684688
{
685689
chainParams = chainParams.loadConfig(configJSON, {}, configPath);
686690
chainConfigIsSet = true;
691+
chainConfigError = false;
692+
}
693+
catch (js::Error_position const& error)
694+
{
695+
cerr << "json parsing error detected on line " << error.line_ << " in column "
696+
<< error.column_ << ": " << error.reason_ << "\n";
687697
}
688698
catch (...)
699+
{
700+
}
701+
if (chainConfigError)
689702
{
690703
cerr << "provided configuration is not well formatted\n";
691-
cerr << "sample: \n" << genesisInfo(eth::Network::MainNetworkTest) << "\n";
692-
return AlethErrors::Success;
704+
cerr << "good configuration sample: \n"
705+
<< genesisInfo(eth::Network::MainNetworkTest) << "\n";
706+
return AlethErrors::ConfigFileInvalid;
693707
}
694708
}
695709

libethcore/Common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ enum AlethErrors
226226
UnknownArgument,
227227
UnknownMiningOption,
228228
ConfigFileEmptyOrNotFound,
229+
ConfigFileInvalid,
229230
UnknownNetworkType,
230231
BadNetworkIdOption,
231232
BadConfigOption,

0 commit comments

Comments
 (0)