Skip to content

Commit 4bebc34

Browse files
committed
handle errors in options better
1 parent 63677c1 commit 4bebc34

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

importer/src/main.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ int main(int argc, char *argv[])
4141

4242
{
4343
po::options_description generic("Geocoder NLP importer options");
44-
generic.add_options()("help", "Help message")("version,v", "Data format version");
44+
generic.add_options()("help,h", "Help message")("version,v", "Data format version");
4545
generic.add_options()("poly,p", po::value<std::string>(&polyjson),
4646
"Boundary of the imported region in GeoJSON format");
4747
generic.add_options()("postal-country", po::value<std::string>(&postal_country_parser),
@@ -70,8 +70,17 @@ int main(int argc, char *argv[])
7070
cmdline_options.add(generic).add(hidden);
7171

7272
po::variables_map vm;
73-
po::store(po::command_line_parser(argc, argv).options(cmdline_options).positional(p).run(), vm);
74-
po::notify(vm);
73+
try
74+
{
75+
po::store(po::command_line_parser(argc, argv).options(cmdline_options).positional(p).run(),
76+
vm);
77+
po::notify(vm);
78+
}
79+
catch (std::exception &e)
80+
{
81+
std::cerr << "Error while parsing options: " << e.what() << "\n\n";
82+
std::cerr << generic << "\n";
83+
}
7584

7685
if (vm.count("help"))
7786
{

0 commit comments

Comments
 (0)