From 150deb0463e7fc5bd46c53acac9d33bc5e602558 Mon Sep 17 00:00:00 2001 From: Sam Jenkins <s.jenkins@stfc.ac.uk> Date: Thu, 19 Jul 2018 10:00:13 +0100 Subject: [PATCH] Caught exception in ICat Caught unhandled exception in ICat caused by inputing a date in an invalid format Re #18529 --- qt/widgets/common/src/CatalogHelper.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/qt/widgets/common/src/CatalogHelper.cpp b/qt/widgets/common/src/CatalogHelper.cpp index 19095919d7c..4def8bd0800 100644 --- a/qt/widgets/common/src/CatalogHelper.cpp +++ b/qt/widgets/common/src/CatalogHelper.cpp @@ -217,6 +217,20 @@ const std::map<std::string, std::string> CatalogHelper::validateProperties( // value. errors.emplace(iter->first + "_err", documentation); } + + } + //catch invalid date formats + std::string dateField ="StartDate"; + try{ + + getTimevalue(catalogAlgorithm->getProperty(dateField)); + dateField="EndDate"; + + getTimevalue(catalogAlgorithm->getProperty(dateField)); + }catch(std::invalid_argument){ + std::string documentation = + propertyDocumentation(catalogAlgorithm->getProperties(), dateField); + errors.emplace(dateField+ "_err", documentation); } return errors; } @@ -238,7 +252,10 @@ time_t CatalogHelper::getTimevalue(const std::string &inputDate) { std::string isoDate = dateSegments.at(2) + "-" + dateSegments.at(1) + "-" + dateSegments.at(0) + " 00:00:00.000"; // Return the date as time_t value. + //temp change once asked how to handle + return Mantid::Types::Core::DateAndTime(isoDate).to_time_t(); + } /** -- GitLab