@@ -56,31 +56,55 @@ int QmlGuiMain(int argc, char* argv[])
56
56
57
57
auto handler_message_box = ::uiInterface.ThreadSafeMessageBox_connect (InitErrorMessageBox);
58
58
59
- // Parse command-line options. We do this after qt in order to show an error if there are problems parsing these.
59
+ NodeContext node_context;
60
+
61
+ // / Parse command-line options. We do this after qt in order to show an error if there are problems parsing these.
62
+ node_context.args = &gArgs ;
60
63
SetupServerArgs (gArgs );
61
64
SetupUIArgs (gArgs );
62
65
std::string error;
63
66
if (!gArgs .ParseParameters (argc, argv, error)) {
64
- InitError (strprintf (Untranslated (" Error parsing command line arguments: %s\n " ), error));
67
+ InitError (strprintf (Untranslated (" Cannot parse command line arguments: %s\n " ), error));
68
+ return EXIT_FAILURE;
69
+ }
70
+
71
+ // / Determine availability of data directory.
72
+ if (!CheckDataDirOption ()) {
73
+ InitError (strprintf (Untranslated (" Specified data directory \" %s\" does not exist.\n " ), gArgs .GetArg (" -datadir" , " " )));
65
74
return EXIT_FAILURE;
66
75
}
67
76
68
- CheckDataDirOption ();
77
+ // / Read and parse bitcoin.conf file.
78
+ if (!gArgs .ReadConfigFiles (error, true )) {
79
+ InitError (strprintf (Untranslated (" Cannot parse configuration file: %s\n " ), error));
80
+ return EXIT_FAILURE;
81
+ }
69
82
70
- gArgs .ReadConfigFiles (error, true );
83
+ // / Check for chain settings (Params() calls are only valid after this clause).
84
+ try {
85
+ SelectParams (gArgs .GetChainName ());
86
+ } catch (std::exception &e) {
87
+ InitError (Untranslated (strprintf (" %s\n " , e.what ())));
88
+ return EXIT_FAILURE;
89
+ }
71
90
72
- SelectParams (gArgs .GetChainName ());
91
+ // / Read and parse settings.json file.
92
+ if (!gArgs .InitSettings (error)) {
93
+ InitError (Untranslated (error));
94
+ return EXIT_FAILURE;
95
+ }
73
96
74
97
// Default printtoconsole to false for the GUI. GUI programs should not
75
98
// print to the console unnecessarily.
76
99
gArgs .SoftSetBoolArg (" -printtoconsole" , false );
77
100
InitLogging (gArgs );
78
101
InitParameterInteraction (gArgs );
79
102
80
- NodeContext node_context;
81
- node_context.args = &gArgs ;
82
103
std::unique_ptr<interfaces::Node> node = interfaces::MakeNode (&node_context);
83
- node->baseInitialize ();
104
+ if (!node->baseInitialize ()) {
105
+ // A dialog with detailed error will have been shown by InitError().
106
+ return EXIT_FAILURE;
107
+ }
84
108
85
109
handler_message_box.disconnect ();
86
110
0 commit comments