Skip to content

Commit aad68eb

Browse files
committed
[fix] exception handling of the sharg-parser
1 parent 2224cd0 commit aad68eb

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/mkindex.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,21 @@ void realMain(LambdaIndexerOptions const & options);
6868
int mkindexMain(int const argc, char const ** argv)
6969
{
7070
LambdaIndexerOptions options;
71+
72+
#ifdef NDEBUG
73+
try
74+
{
75+
parseCommandLine(options, argc, argv);
76+
}
77+
catch (sharg::parser_error const & ext) // catch user errors
78+
{
79+
std::cerr << "\n\nERROR: during command line parsing\n"
80+
<< " \"" << ext.what() << "\"\n";
81+
return -1;
82+
}
83+
#else
7184
parseCommandLine(options, argc, argv);
85+
#endif
7286

7387
#ifdef NDEBUG
7488
try

src/search.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,21 @@ void realMain(LambdaOptions const & options);
7373
int searchMain(int const argc, char const ** argv)
7474
{
7575
LambdaOptions options;
76+
77+
#ifdef NDEBUG
78+
try
79+
{
80+
parseCommandLine(options, argc, argv);
81+
}
82+
catch (sharg::parser_error const & ext) // catch user errors
83+
{
84+
std::cerr << "\n\nERROR: during command line parsing\n"
85+
<< " \"" << ext.what() << "\"\n";
86+
return -1;
87+
}
88+
#else
7689
parseCommandLine(options, argc, argv);
90+
#endif
7791

7892
#ifdef _OPENMP
7993
omp_set_num_threads(options.threads - options.lazyQryFile); // reserve one thread for I/O when lazy-loading

0 commit comments

Comments
 (0)