[hamradio-commits] [gnss-sdr] 104/251: Handling error if logging directory can't be created
Carles Fernandez
carles_fernandez-guest at moszumanska.debian.org
Wed Sep 2 00:22:40 UTC 2015
This is an automated email from the git hooks/post-receive script.
carles_fernandez-guest pushed a commit to branch master
in repository gnss-sdr.
commit aa18634c87a2f6983cee24de5817fb214efccdf3
Author: Carles Fernandez <carles.fernandez at gmail.com>
Date: Tue May 19 18:20:28 2015 +0200
Handling error if logging directory can't be created
---
src/main/main.cc | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/src/main/main.cc b/src/main/main.cc
index 4382d89..a26e8b5 100644
--- a/src/main/main.cc
+++ b/src/main/main.cc
@@ -35,6 +35,7 @@
#endif
#include <ctime>
+#include <cstdlib>
#include <memory>
#include <queue>
#include <boost/exception/diagnostic_information.hpp>
@@ -145,13 +146,19 @@ int main(int argc, char** argv)
if (!boost::filesystem::exists(p))
{
std::cout << "The path "
- << FLAGS_log_dir
- << " does not exist, attempting to create it"
- << std::endl;
- boost::filesystem::create_directory(p);
+ << FLAGS_log_dir
+ << " does not exist, attempting to create it."
+ << std::endl;
+ boost::system::error_code ec;
+ boost::filesystem::create_directory(p, ec);
+ if(ec != 0)
+ {
+ std::cout << "Could not create the " << FLAGS_log_dir << " folder. GNSS-SDR program ended." << std::endl;
+ google::ShutDownCommandLineFlags();
+ std::exit(0);
+ }
}
- std::cout << "Logging with be done at "
- << FLAGS_log_dir << std::endl;
+ std::cout << "Logging with be done at " << FLAGS_log_dir << std::endl;
}
std::unique_ptr<ControlThread> control_thread(new ControlThread());
@@ -169,6 +176,10 @@ int main(int argc, char** argv)
{
LOG(FATAL) << "Boost exception: " << boost::diagnostic_information(e);
}
+ catch( boost::lock_error & le )
+ {
+ LOG(FATAL) << "Lock error exception: " << boost::diagnostic_information(le);
+ }
catch(std::exception const& ex)
{
LOG(FATAL) << "STD exception: " << ex.what();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/gnss-sdr.git
More information about the pkg-hamradio-commits
mailing list