1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-07-03 10:32:55 +00:00

Catch all exceptions

This commit is contained in:
Carles Fernandez 2017-08-15 12:47:58 +02:00
parent f8c7f1422b
commit 99f5c69afc

View File

@ -23,20 +23,23 @@
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <volk_gnsssdr/volk_gnsssdr_prefs.h>
#include <ciso646>
//#include <ciso646>
#include <vector>
#include <boost/exception/diagnostic_information.hpp>
#include <boost/filesystem.hpp>
#include <boost/program_options.hpp>
#include <boost/xpressive/xpressive.hpp>
#include <iostream>
#include <fstream>
#include <sys/stat.h>
#include <sys/types.h>
//#include <sys/stat.h>
//#include <sys/types.h>
namespace fs = boost::filesystem;
int main(int argc, char *argv[]) {
// Adding program options
try
{
boost::program_options::options_description desc("Options");
desc.add_options()
("help,h", "Print help messages")
@ -108,7 +111,7 @@ int main(int argc, char *argv[]) {
update_mode = vm["update"].as<bool>();
dry_run = vm["dry-run"].as<bool>();
}
catch (boost::program_options::error& error) {
catch (const boost::program_options::error & error) {
std::cerr << "Error: " << error.what() << std::endl << std::endl;
std::cerr << desc << std::endl;
return 1;
@ -126,7 +129,7 @@ int main(int argc, char *argv[]) {
try {
filename = vm["json"].as<std::string>();
}
catch (boost::bad_any_cast& error) {
catch (const boost::bad_any_cast& error) {
std::cerr << error.what() << std::endl;
return 1;
}
@ -137,7 +140,7 @@ int main(int argc, char *argv[]) {
try {
config_file = vm["path"].as<std::string>() + "/volk_config";
}
catch (boost::bad_any_cast& error) {
catch (const boost::bad_any_cast& error) {
std::cerr << error.what() << std::endl;
return 1;
}
@ -162,7 +165,7 @@ int main(int argc, char *argv[]) {
try {
kernel_expression = boost::xpressive::sregex::compile(kernel_regex);
}
catch (boost::xpressive::regex_error& error) {
catch (const boost::xpressive::regex_error& error) {
std::cerr << "Error occurred while compiling regex" << std::endl << std::endl;
return 1;
}
@ -198,7 +201,7 @@ int main(int argc, char *argv[]) {
run_volk_gnsssdr_tests(test_case.desc(), test_case.kernel_ptr(), test_case.name(),
test_case.test_parameters(), &results, test_case.puppet_master_name());
}
catch (std::string error) {
catch (const std::string & error) {
std::cerr << "Caught Exception in 'run_volk_gnsssdr_tests': " << error << std::endl;
}
@ -220,6 +223,12 @@ int main(int argc, char *argv[]) {
else {
std::cout << "Warning: this was a dry-run. Config not generated" << std::endl;
}
}
catch(const boost::exception & e)
{
std::cerr << boost::diagnostic_information(e) << std::endl;
return 1;
}
}
void read_results(std::vector<volk_gnsssdr_test_results_t> *results)