mirror of https://github.com/gnss-sdr/gnss-sdr
Try hard to not throw in main
This commit is contained in:
parent
0d60e46390
commit
56292fb00c
|
@ -11,7 +11,7 @@
|
||||||
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||||
* This file is part of GNSS-SDR.
|
* This file is part of GNSS-SDR.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)
|
* Copyright (C) 2010-2013 (see AUTHORS file for a list of contributors)
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*
|
*
|
||||||
* -----------------------------------------------------------------------------
|
* -----------------------------------------------------------------------------
|
||||||
|
@ -65,17 +65,26 @@ Concurrent_Map<Gps_Acq_Assist> global_gps_acq_assist_map;
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
const std::string intro_help(
|
try
|
||||||
std::string("\nGNSS-SDR is an Open Source GNSS Software Defined Receiver\n") +
|
{
|
||||||
"Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors)\n" +
|
const std::string intro_help(
|
||||||
"This program comes with ABSOLUTELY NO WARRANTY;\n" +
|
std::string("\nGNSS-SDR is an Open Source GNSS Software Defined Receiver\n") +
|
||||||
"See COPYING file to see a copy of the General Public License\n \n");
|
"Copyright (C) 2010-2023 (see AUTHORS file for a list of contributors)\n" +
|
||||||
|
"This program comes with ABSOLUTELY NO WARRANTY;\n" +
|
||||||
|
"See COPYING file to see a copy of the General Public License\n \n");
|
||||||
|
|
||||||
const std::string gnss_sdr_version(GNSS_SDR_VERSION);
|
const std::string gnss_sdr_version(GNSS_SDR_VERSION);
|
||||||
gflags::SetUsageMessage(intro_help);
|
gflags::SetUsageMessage(intro_help);
|
||||||
gflags::SetVersionString(gnss_sdr_version);
|
gflags::SetVersionString(gnss_sdr_version);
|
||||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||||
std::cout << "Initializing GNSS-SDR v" << gnss_sdr_version << " ... Please wait.\n";
|
std::cout << "Initializing GNSS-SDR v" << gnss_sdr_version << " ... Please wait.\n";
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
std::cerr << e.what() << '\n';
|
||||||
|
std::cout << "GNSS-SDR program ended.\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
#if CUDA_GPU_ACCEL
|
#if CUDA_GPU_ACCEL
|
||||||
// Reset the device
|
// Reset the device
|
||||||
|
@ -100,21 +109,31 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const fs::path p(FLAGS_log_dir);
|
try
|
||||||
if (!fs::exists(p))
|
|
||||||
{
|
{
|
||||||
std::cout << "The path "
|
const fs::path p(FLAGS_log_dir);
|
||||||
<< FLAGS_log_dir
|
if (!fs::exists(p))
|
||||||
<< " does not exist, attempting to create it.\n";
|
|
||||||
errorlib::error_code ec;
|
|
||||||
if (!fs::create_directory(p, ec))
|
|
||||||
{
|
{
|
||||||
std::cerr << "Could not create the " << FLAGS_log_dir << " folder. GNSS-SDR program ended.\n";
|
std::cout << "The path "
|
||||||
gflags::ShutDownCommandLineFlags();
|
<< FLAGS_log_dir
|
||||||
return 1;
|
<< " does not exist, attempting to create it.\n";
|
||||||
|
errorlib::error_code ec;
|
||||||
|
if (!fs::create_directory(p, ec))
|
||||||
|
{
|
||||||
|
std::cerr << "Could not create the " << FLAGS_log_dir << " folder. GNSS-SDR program ended.\n";
|
||||||
|
gflags::ShutDownCommandLineFlags();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
std::cout << "Logging will be written at " << FLAGS_log_dir << '\n';
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
std::cerr << e.what() << '\n';
|
||||||
|
std::cerr << "Could not create the " << FLAGS_log_dir << " folder. GNSS-SDR program ended.\n";
|
||||||
|
gflags::ShutDownCommandLineFlags();
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
std::cout << "Logging will be written at " << FLAGS_log_dir << '\n';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,9 +151,7 @@ int main(int argc, char** argv)
|
||||||
catch (const boost::thread_resource_error& e)
|
catch (const boost::thread_resource_error& e)
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to create boost thread.\n";
|
std::cerr << "Failed to create boost thread.\n";
|
||||||
gflags::ShutDownCommandLineFlags();
|
return_code = 1;
|
||||||
std::cout << "GNSS-SDR program ended.\n";
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
catch (const boost::exception& e)
|
catch (const boost::exception& e)
|
||||||
{
|
{
|
||||||
|
@ -147,9 +164,7 @@ int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
std::cerr << "Boost exception: " << boost::diagnostic_information(e) << '\n';
|
std::cerr << "Boost exception: " << boost::diagnostic_information(e) << '\n';
|
||||||
}
|
}
|
||||||
gflags::ShutDownCommandLineFlags();
|
return_code = 1;
|
||||||
std::cout << "GNSS-SDR program ended.\n";
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& ex)
|
catch (const std::exception& ex)
|
||||||
{
|
{
|
||||||
|
@ -162,9 +177,7 @@ int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
std::cerr << "C++ Standard Library exception: " << ex.what() << '\n';
|
std::cerr << "C++ Standard Library exception: " << ex.what() << '\n';
|
||||||
}
|
}
|
||||||
gflags::ShutDownCommandLineFlags();
|
return_code = 1;
|
||||||
std::cout << "GNSS-SDR program ended.\n";
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
@ -177,9 +190,7 @@ int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
std::cerr << "Unexpected catch. This should not happen.\n";
|
std::cerr << "Unexpected catch. This should not happen.\n";
|
||||||
}
|
}
|
||||||
gflags::ShutDownCommandLineFlags();
|
return_code = 1;
|
||||||
std::cout << "GNSS-SDR program ended.\n";
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// report the elapsed time
|
// report the elapsed time
|
||||||
|
|
Loading…
Reference in New Issue