Commit cbb751de authored by Simon Spannagel's avatar Simon Spannagel
Browse files

EventLoaders: throw if input data is missing

parent 45a41171
Pipeline #2027073 passed with stages
in 30 minutes and 13 seconds
......@@ -59,8 +59,7 @@ void EventLoaderATLASpix::initialize() {
// Open the root directory
DIR* directory = opendir(m_inputDirectory.c_str());
if(directory == nullptr) {
LOG(ERROR) << "Directory " << m_inputDirectory << " does not exist";
return;
throw ModuleError("Directory " + m_inputDirectory + " does not exist");
}
dirent* entry;
......@@ -75,10 +74,9 @@ void EventLoaderATLASpix::initialize() {
// If no data was loaded, give a warning
if(m_filename.length() == 0) {
LOG(WARNING) << "No data file was found for ATLASpix in " << m_inputDirectory;
} else {
LOG(STATUS) << "Opened data file for ATLASpix: (dbg)" << m_filename;
throw ModuleError("No data file was found for ATLASpix in " + m_inputDirectory);
}
LOG(STATUS) << "Opened data file for ATLASpix: (dbg)" << m_filename;
// Open the binary data file for later
m_file.open(m_filename.c_str(), ios::in | ios::binary);
......
......@@ -43,8 +43,9 @@ void EventLoaderCLICpix::initialize() {
}
// If no data was loaded, give a warning
if(m_filename.length() == 0)
LOG(WARNING) << "No data file was found for CLICpix in " << inputDirectory;
if(m_filename.length() == 0) {
throw ModuleError("No data file was found for CLICpix in " + inputDirectory);
}
// Open the data file for later
m_file.open(m_filename.c_str());
......
......@@ -63,7 +63,7 @@ void EventLoaderCLICpix2::initialize() {
matrix_config = clicpix2_utils::readMatrix(m_matrix);
// If no data was loaded, give a warning
if(m_filename.empty()) {
LOG(WARNING) << "No data file was found for CLICpix2 in " << inputDirectory;
throw ModuleError("No data file was found for CLICpix2 in " + inputDirectory);
}
// Open the data file for later
......
......@@ -52,8 +52,7 @@ void EventLoaderTimepix1::initialize() {
// Open the directory
DIR* directory = opendir(m_inputDirectory.c_str());
if(directory == nullptr) {
LOG(ERROR) << "Directory " << m_inputDirectory << " does not exist";
return;
throw ModuleError("Directory " + m_inputDirectory + " does not exist");
}
dirent* entry;
......@@ -72,6 +71,10 @@ void EventLoaderTimepix1::initialize() {
}
}
if(m_inputFilenames.empty()) {
throw ModuleError("Could not find any data files in directory " + m_inputDirectory);
}
// Now sort the list of filenames by time (included in the title) from
// earliest to latest
std::sort(m_inputFilenames.begin(), m_inputFilenames.end(), sortByTime);
......
......@@ -96,9 +96,8 @@ void EventLoaderTimepix3::initialize() {
// Check that we have files for this detector and sort them correctly:
if(detector_files.empty()) {
LOG(ERROR) << "No data file found for detector " << m_detector->getName() << " in input directory " << std::endl
<< m_inputDirectory;
return;
throw ModuleError("No data file found for detector " + m_detector->getName() + " in input directory " +
m_inputDirectory);
}
// Initialise null values for later
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment