From 370382d44dce21565fcd7e640f9207185df001e7 Mon Sep 17 00:00:00 2001 From: tastytea Date: Thu, 20 May 2021 09:05:52 +0200 Subject: [PATCH] Add basic error handling. --- src/main.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 62ad6fa..a7c386d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,13 +17,19 @@ #include "options.hpp" #include +#include +#include #include +#include #include #include 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) {