Skip to content

Commit

Permalink
have EventFile throw exceptions in the no-skip case
Browse files Browse the repository at this point in the history
still check isCorrupted after opening and throw a BadCode error if we
aren't skipping since EventFile should make sure its input file is not
corrupted during construction
  • Loading branch information
tomeichlersmith committed Sep 6, 2024
1 parent 5092c9b commit 9a77271
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
23 changes: 19 additions & 4 deletions Framework/src/Framework/EventFile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,28 @@ EventFile::EventFile(const framework::config::Parameters &params,
"' is not readable or does not exist.");
}

bool skip_corrupted = params.getParameter<bool>("skipCorruptedInputFiles", false);

// make sure file is not a zombie file
// (i.e. process ended without closing or the file was corrupted some other way)
if (file_->IsZombie()) {
if (not skip_corrupted) {
EXCEPTION_RAISE("FileError", "Input file '" + fileName_ +
"' is corrupted. Framework will not attempt to recover this file.");
}
return;
}

// Get the tree name from the configuration
auto tree_name{params.getParameter<std::string>("tree_name")};
tree_ = static_cast<TTree *>(file_->Get(tree_name.c_str()));
if (!tree_ and not params.getParameter<bool>("skipCorruptedInputFiles", false)) {
EXCEPTION_RAISE("FileError", "File '" + fileName_ +
"' does not have a TTree named '" +
tree_name + "' in it.");
if (!tree_) {
if (not skip_corrupted) {
EXCEPTION_RAISE("FileError", "File '" + fileName_ +
"' does not have a TTree named '" +
tree_name + "' in it.");
}
return;
}
entries_ = tree_->GetEntriesFast();
}
Expand Down
6 changes: 4 additions & 2 deletions Framework/src/Framework/Process.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,10 @@ void Process::run() {
continue;
} else {
EXCEPTION_RAISE(
"FileErr",
"Input file '"+infilename+"' is corrupted (not readable by Framework)."
"BadCode",
"We should never get here. "
"EventFile is corrupted but we aren't skipping corrupted inputs. "
"EventFile should be throwing its own exceptions in this case."
);
}
}
Expand Down

0 comments on commit 9a77271

Please sign in to comment.