Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show error message when data logger fails to write #75

Open
wants to merge 1 commit into
base: ros2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions terrain_navigation/src/data_logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

#include <fstream>
#include <iostream>
#include <cstring>

DataLogger::DataLogger() {}

Expand All @@ -53,6 +54,10 @@ void DataLogger::writeToFile(const std::string path) {
std::cout << "[DataLogger] Writing data to file! " << path << std::endl;
std::ofstream output_file;
output_file.open(path, std::ios::trunc);
if (output_file.fail()) {
std::cerr << "[DataLogger]: Failed to write to file: " << path << " with error " << strerror(errno) << std::endl;
return;
}
if (print_header_) {
for (auto key : keys_) {
output_file << key << field_seperator;
Expand Down
Loading