summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRALOVICH, Kristof <tade60@freemail.hu>2015-05-31 19:07:29 +0200
committerRALOVICH, Kristof <tade60@freemail.hu>2015-05-31 19:07:29 +0200
commit613201ed08f54e1677605b0850a7c57790829c01 (patch)
treed4776c2363a6b5337abaf8eefb1fd9161d535aec
parent86e2e304252ed113214b99f3e04fe2bf2cdefc72 (diff)
antpm: exception safety
-rw-r--r--src/antpm-downloader.cpp5
-rw-r--r--src/antpm-fit2gpx.cpp16
-rw-r--r--src/antpm-usbmon2ant.cpp6
3 files changed, 22 insertions, 5 deletions
diff --git a/src/antpm-downloader.cpp b/src/antpm-downloader.cpp
index 6c7f5d9..1bdea95 100644
--- a/src/antpm-downloader.cpp
+++ b/src/antpm-downloader.cpp
@@ -186,6 +186,11 @@ main(int argc, char** argv)
cerr << desc << "\n";
return EXIT_FAILURE;
}
+ catch(boost::exception& e)
+ {
+ cerr << boost::diagnostic_information(e) << std::endl;
+ return EXIT_FAILURE;
+ }
catch(std::exception& ex)
{
cerr << ex.what() << "\n";
diff --git a/src/antpm-fit2gpx.cpp b/src/antpm-fit2gpx.cpp
index d78b25f..c5974f1 100644
--- a/src/antpm-fit2gpx.cpp
+++ b/src/antpm-fit2gpx.cpp
@@ -29,6 +29,7 @@
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
+#include <boost/exception/diagnostic_information.hpp>
namespace po = boost::program_options;
namespace fs = boost::filesystem;
@@ -91,7 +92,11 @@ main(int argc, char** argv)
bool fixLastWrt = false;
int verbosityLevel = antpm::Log::instance()->getLogReportingLevel();
po::options_description desc("Allowed options");
- desc.add_options()
+ std::vector<const char*> args(argv, argv+argc);
+ po::variables_map vm;
+ try
+ {
+ desc.add_options()
("help,h", "produce help message")
("fitFolder,F", po::value<std::string>(&fitFolder), "Folder with FIT files")
("decode-fit-root,D", po::value<std::string>(&fitRootFile), "FIT file, encoding the root directory contents on a device, e.g. /tmp/0000.fit")
@@ -100,10 +105,6 @@ main(int argc, char** argv)
("version,V", "Print version information")
;
- std::vector<const char*> args(argv, argv+argc);
- po::variables_map vm;
- try
- {
//po::parsed_options parsed = po::parse_command_line(argc, argv, desc);
po::parsed_options parsed = po::command_line_parser(argc, argv).options(desc).run();
po::store(parsed, vm);
@@ -115,6 +116,11 @@ main(int argc, char** argv)
cerr << desc << "\n";
return EXIT_FAILURE;
}
+ catch(boost::exception& e)
+ {
+ cerr << boost::diagnostic_information(e) << std::endl;
+ return EXIT_FAILURE;
+ }
catch(std::exception& ex)
{
cerr << ex.what() << "\n";
diff --git a/src/antpm-usbmon2ant.cpp b/src/antpm-usbmon2ant.cpp
index a7aae53..68e4192 100644
--- a/src/antpm-usbmon2ant.cpp
+++ b/src/antpm-usbmon2ant.cpp
@@ -27,6 +27,7 @@
#include "Log.hpp"
#include <boost/program_options.hpp>
+#include <boost/exception/diagnostic_information.hpp>
namespace po = boost::program_options;
using namespace std;
@@ -90,6 +91,11 @@ main(int argc, char** argv)
cerr << desc << "\n";
return EXIT_FAILURE;
}
+ catch(boost::exception& e)
+ {
+ cerr << boost::diagnostic_information(e) << std::endl;
+ return EXIT_FAILURE;
+ }
catch(std::exception& ex)
{
cerr << ex.what() << "\n";