Don't crash on regex errors.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
The error will be reported once for each initial thread. Closes: #14
This commit is contained in:
parent
18c3d8f58d
commit
822bff1955
17
src/main.cpp
17
src/main.cpp
|
@ -45,6 +45,8 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
constexpr int EXIT_FATAL{2};
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
using namespace epubgrep;
|
using namespace epubgrep;
|
||||||
|
@ -77,7 +79,7 @@ int main(int argc, char *argv[])
|
||||||
{ // Exceptions we can't recover from or ones we don't know.
|
{ // Exceptions we can't recover from or ones we don't know.
|
||||||
LOG(log::sev::fatal)
|
LOG(log::sev::fatal)
|
||||||
<< e.what() << translate(" (while parsing options)");
|
<< e.what() << translate(" (while parsing options)");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FATAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts.debug)
|
if (opts.debug)
|
||||||
|
@ -175,6 +177,11 @@ int main(int argc, char *argv[])
|
||||||
filepath);
|
filepath);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
catch (const boost::regex_error &e)
|
||||||
|
{
|
||||||
|
LOG(log::sev::fatal) << e.what();
|
||||||
|
return EXIT_FATAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
@ -219,6 +226,10 @@ int main(int argc, char *argv[])
|
||||||
DEBUGLOG << "Attempting to clean up threads";
|
DEBUGLOG << "Attempting to clean up threads";
|
||||||
futures_cleanup();
|
futures_cleanup();
|
||||||
}
|
}
|
||||||
|
if (return_code == EXIT_FATAL)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
futurepool.emplace_back(
|
futurepool.emplace_back(
|
||||||
std::async(std::launch::async, search_file, filepath));
|
std::async(std::launch::async, search_file, filepath));
|
||||||
DEBUGLOG << "Launched new thread";
|
DEBUGLOG << "Launched new thread";
|
||||||
|
@ -233,6 +244,10 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
DEBUGLOG << "Waiting for remaining threads to finish";
|
DEBUGLOG << "Waiting for remaining threads to finish";
|
||||||
futures_cleanup(true);
|
futures_cleanup(true);
|
||||||
|
if (return_code == EXIT_FATAL)
|
||||||
|
{
|
||||||
|
return EXIT_FATAL;
|
||||||
|
}
|
||||||
|
|
||||||
if (opts.json)
|
if (opts.json)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user