Skip to content

Commit

Permalink
handling underlying OS API errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kjvbrt committed Jan 25, 2024
1 parent 74c277c commit 763bdb1
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions k4FWCore/components/PodioOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/
#include <cstdlib>
#include <filesystem>
#include <system_error>

#include "GaudiKernel/MsgStream.h"

#include "PodioOutput.h"
#include "k4FWCore/PodioDataSvc.h"
Expand All @@ -39,18 +42,19 @@ StatusCode PodioOutput::initialize() {
return StatusCode::FAILURE;
}

// check whether output directory needs to be created and eventualy create it
// check whether output directory needs to be created and eventually create it
auto outDirPath = std::filesystem::path(m_filename.value()).parent_path();
if (!outDirPath.empty() && !std::filesystem::is_directory(outDirPath)) {
debug() << "Creating output directory:" << endmsg;
debug() << outDirPath << endmsg;
auto success = std::filesystem::create_directories(outDirPath);
if (!success) {
error() << "Output directory can't be created!" << endmsg;
error() << outDirPath << endmsg;
std::error_code ec;
std::filesystem::create_directories(outDirPath, ec);
if (ec.value() != 0) {
error() << "Output directory \""<< outDirPath << "\" was not created!"
<< endmsg;
error() << "Error " << ec.value() << ": " << ec.message() << endmsg;

return StatusCode::FAILURE;
}
debug() << "Created output directory: " << outDirPath << endmsg;
}

m_framewriter = std::make_unique<podio::ROOTFrameWriter>(m_filename);
Expand Down

0 comments on commit 763bdb1

Please sign in to comment.