mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-06-22 16:34:08 +00:00
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
|
||||||
*
|
*
|
||||||
* -----------------------------------------------------------------------------
|
* -----------------------------------------------------------------------------
|
||||||
@ -64,10 +64,12 @@ Concurrent_Queue<Gps_Acq_Assist> global_gps_acq_assist_queue;
|
|||||||
Concurrent_Map<Gps_Acq_Assist> global_gps_acq_assist_map;
|
Concurrent_Map<Gps_Acq_Assist> global_gps_acq_assist_map;
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
const std::string intro_help(
|
const std::string intro_help(
|
||||||
std::string("\nGNSS-SDR is an Open Source GNSS Software Defined Receiver\n") +
|
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" +
|
"Copyright (C) 2010-2023 (see AUTHORS file for a list of contributors)\n" +
|
||||||
"This program comes with ABSOLUTELY NO WARRANTY;\n" +
|
"This program comes with ABSOLUTELY NO WARRANTY;\n" +
|
||||||
"See COPYING file to see a copy of the General Public License\n \n");
|
"See COPYING file to see a copy of the General Public License\n \n");
|
||||||
|
|
||||||
@ -76,6 +78,13 @@ int main(int argc, char** argv)
|
|||||||
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
|
||||||
@ -99,6 +108,8 @@ int main(int argc, char** argv)
|
|||||||
<< "Use gnss-sdr --log_dir=/path/to/log to change that.\n";
|
<< "Use gnss-sdr --log_dir=/path/to/log to change that.\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
const fs::path p(FLAGS_log_dir);
|
const fs::path p(FLAGS_log_dir);
|
||||||
if (!fs::exists(p))
|
if (!fs::exists(p))
|
||||||
@ -116,6 +127,14 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
std::cout << "Logging will be written at " << FLAGS_log_dir << '\n';
|
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::chrono::time_point<std::chrono::system_clock> start;
|
std::chrono::time_point<std::chrono::system_clock> start;
|
||||||
@ -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…
x
Reference in New Issue
Block a user