Add basic error handling.
This commit is contained in:
parent
f95389d76c
commit
370382d44d
17
src/main.cpp
17
src/main.cpp
|
@ -17,13 +17,19 @@
|
||||||
#include "options.hpp"
|
#include "options.hpp"
|
||||||
|
|
||||||
#include <boost/locale/generator.hpp>
|
#include <boost/locale/generator.hpp>
|
||||||
|
#include <boost/program_options/errors.hpp>
|
||||||
|
#include <boost/program_options/variables_map.hpp>
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <exception>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
namespace po = boost::program_options;
|
||||||
|
|
||||||
|
using std::cerr;
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
|
||||||
boost::locale::generator locale_generator;
|
boost::locale::generator locale_generator;
|
||||||
|
@ -33,7 +39,16 @@ int main(int argc, char *argv[])
|
||||||
std::locale::global(locale_generator(""));
|
std::locale::global(locale_generator(""));
|
||||||
cout.imbue(std::locale());
|
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)
|
if (vm.count("help") + vm.count("version") > 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user