Skip to content
Snippets Groups Projects
Commit 91e659b0 authored by Russell Taylor's avatar Russell Taylor
Browse files

Re #8638. Catch invalid start times.

Catch the exception if the contents of the run_start or start_time
properties cannot be turned into a valid DateAndTime. Turn it into the
exception for a generic failure of this method.
parent 1fb224da
No related merge requests found
......@@ -89,24 +89,28 @@ Kernel::Logger& LogManager::g_log = Kernel::Logger::get("LogManager");
const std::string start_prop("start_time");
if (this->hasProperty(start_prop))
{
std::string start = this->getProperty(start_prop)->value();
if (DateAndTime(start) != DateAndTimeHelpers::GPS_EPOCH)
{
return DateAndTime(start);
}
try {
DateAndTime start_time(getProperty(start_prop)->value());
if (start_time != DateAndTimeHelpers::GPS_EPOCH)
{
return start_time;
}
} catch (std::invalid_argument&) { /*Swallow and move on*/ }
}
const std::string run_start_prop("run_start");
if (this->hasProperty(run_start_prop))
{
std::string start = this->getProperty(run_start_prop)->value();
if (DateAndTime(start) != DateAndTimeHelpers::GPS_EPOCH)
{
return DateAndTime(start);
}
try {
DateAndTime start_time(getProperty(run_start_prop)->value());
if (start_time != DateAndTimeHelpers::GPS_EPOCH)
{
return start_time;
}
} catch (std::invalid_argument&) { /*Swallow and move on*/ }
}
throw std::runtime_error("Run::startTime() - No start time has been set for this run.");
throw std::runtime_error("No valid start time has been set for this run.");
}
/** Return the run end time as given by the 'end_time' or 'run_end' property.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment