Skip to content

Commit

Permalink
[fix] exception handling of the sharg-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
h-2 committed Nov 21, 2023
1 parent dc73fbf commit 9aeac71
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/mkindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,21 @@ void realMain(LambdaIndexerOptions const & options);
int mkindexMain(int const argc, char const ** argv)
{
LambdaIndexerOptions options;

#ifdef NDEBUG
try
{
parseCommandLine(options, argc, argv);
}
catch (sharg::parser_error const & ext) // catch user errors
{
std::cerr << "\n\nERROR: during command line parsing\n"
<< " \"" << ext.what() << "\"\n";
return -1;
}
#else
parseCommandLine(options, argc, argv);
#endif

#ifdef NDEBUG
try
Expand Down
14 changes: 14 additions & 0 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,21 @@ void realMain(LambdaOptions const & options);
int searchMain(int const argc, char const ** argv)
{
LambdaOptions options;

#ifdef NDEBUG
try
{
parseCommandLine(options, argc, argv);
}
catch (sharg::parser_error const & ext) // catch user errors
{
std::cerr << "\n\nERROR: during command line parsing\n"
<< " \"" << ext.what() << "\"\n";
return -1;
}
#else
parseCommandLine(options, argc, argv);
#endif

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

0 comments on commit 9aeac71

Please sign in to comment.