Add basic error handling.

This commit is contained in:
tastytea 2021-05-20 09:05:52 +02:00
parent f95389d76c
commit 370382d44d
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 16 additions and 1 deletions

View File

@ -17,13 +17,19 @@
#include "options.hpp"
#include <boost/locale/generator.hpp>
#include <boost/program_options/errors.hpp>
#include <boost/program_options/variables_map.hpp>
#include <cstdlib>
#include <exception>
#include <iostream>
#include <locale>
int main(int argc, char *argv[])
{
namespace po = boost::program_options;
using std::cerr;
using std::cout;
boost::locale::generator locale_generator;
@ -33,7 +39,16 @@ int main(int argc, char *argv[])
std::locale::global(locale_generator(""));
cout.imbue(std::locale());
auto vm{epubgrep::parse_options(argc, argv)};
po::variables_map vm;
try
{
vm = epubgrep::parse_options(argc, argv);
}
catch (std::exception &e)
{ // Exceptions we can't recover from or ones we don't know.
cerr << "ERROR: " << e.what() << '\n';
return EXIT_FAILURE;
}
if (vm.count("help") + vm.count("version") > 0)
{