Skip to content

Commit

Permalink
Improve error messages when opening a bad file (#559)
Browse files Browse the repository at this point in the history
Co-authored-by: jmcarcell <jmcarcell@users.noreply.github.com>
  • Loading branch information
jmcarcell and jmcarcell authored Feb 19, 2024
1 parent 93d69cd commit 894e8b8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ROOTLegacyReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void ROOTLegacyReader::openFiles(const std::vector<std::string>& filenames) {
//-1 forces the headers to be read so that
// the validity of the files can be checked
if (!m_chain->Add(filename.c_str(), -1)) {
throw std::runtime_error("File " + filename + " couldn't be found");
throw std::runtime_error("File " + filename + " couldn't be found or the \"events\" tree couldn't be read.");
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/ROOTReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ void ROOTReader::openFiles(const std::vector<std::string>& filenames) {
// Reading all files is done to check that all file exists
for (const auto& filename : filenames) {
if (!m_metaChain->Add(filename.c_str(), -1)) {
throw std::runtime_error("File " + filename + " couldn't be found");
throw std::runtime_error("File " + filename + " couldn't be found or the \"" + root_utils::metaTreeName +
"\" tree couldn't be read.");
}
}

Expand Down

0 comments on commit 894e8b8

Please sign in to comment.