handle EPC config file errors gracefully

master
Andre Puschmann 6 years ago
parent 3ad19f21b6
commit 41c85adaf2

@ -110,6 +110,7 @@ void parse_args(all_args_t* args, int argc, char* argv[])
// Command line or config file options // Command line or config file options
bpo::options_description common("Configuration options"); bpo::options_description common("Configuration options");
// clang-format off
common.add_options() common.add_options()
("mme.mme_code", bpo::value<string>(&mme_code)->default_value("0x01"), "MME Code") ("mme.mme_code", bpo::value<string>(&mme_code)->default_value("0x01"), "MME Code")
("mme.name", bpo::value<string>(&mme_name)->default_value("srsmme01"), "MME Name") ("mme.name", bpo::value<string>(&mme_name)->default_value("srsmme01"), "MME Name")
@ -158,6 +159,8 @@ void parse_args(all_args_t* args, int argc, char* argv[])
position.add_options() position.add_options()
("config_file", bpo::value< string >(&config_file), "MME configuration file") ("config_file", bpo::value< string >(&config_file), "MME configuration file")
; ;
// clang-format on
bpo::positional_options_description p; bpo::positional_options_description p;
p.add("config_file", -1); p.add("config_file", -1);
@ -197,8 +200,14 @@ void parse_args(all_args_t* args, int argc, char* argv[])
cout << "Failed to read configuration file " << config_file << " - exiting" << endl; cout << "Failed to read configuration file " << config_file << " - exiting" << endl;
exit(1); exit(1);
} }
// parse config file and handle errors gracefully
try {
bpo::store(bpo::parse_config_file(conf, common), vm); bpo::store(bpo::parse_config_file(conf, common), vm);
bpo::notify(vm); bpo::notify(vm);
} catch (const boost::program_options::error& e) {
cerr << e.what() << endl;
exit(1);
}
//Concert hex strings //Concert hex strings
{ {

Loading…
Cancel
Save