From 763bdb1f5379876625600845fdf3bb8d8f60a70f Mon Sep 17 00:00:00 2001 From: Juraj Smiesko Date: Thu, 25 Jan 2024 10:02:38 +0100 Subject: [PATCH] handling underlying OS API errors --- k4FWCore/components/PodioOutput.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/k4FWCore/components/PodioOutput.cpp b/k4FWCore/components/PodioOutput.cpp index c019cd11..a3347504 100644 --- a/k4FWCore/components/PodioOutput.cpp +++ b/k4FWCore/components/PodioOutput.cpp @@ -18,6 +18,9 @@ */ #include #include +#include + +#include "GaudiKernel/MsgStream.h" #include "PodioOutput.h" #include "k4FWCore/PodioDataSvc.h" @@ -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(m_filename);