From 91e659b026d2afb33d32b3dda30f0bb7af06c6da Mon Sep 17 00:00:00 2001
From: Russell Taylor <taylorrj@ornl.gov>
Date: Thu, 19 Dec 2013 14:33:03 -0500
Subject: [PATCH] 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.
---
 Code/Mantid/Framework/API/src/LogManager.cpp | 26 +++++++++++---------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/Code/Mantid/Framework/API/src/LogManager.cpp b/Code/Mantid/Framework/API/src/LogManager.cpp
index 2ead05bfe63..1fea9b3297f 100644
--- a/Code/Mantid/Framework/API/src/LogManager.cpp
+++ b/Code/Mantid/Framework/API/src/LogManager.cpp
@@ -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.
-- 
GitLab