From 6472571db7dc00292b692d6b0bec50ff5b1a2371 Mon Sep 17 00:00:00 2001
From: Nick Draper <nick.draper@stfc.ac.uk>
Date: Tue, 17 Nov 2015 12:10:18 +0000
Subject: [PATCH] Catch potential errors on startup of Mantid

if .mantid or %appdata% directory permissions do not allow writing
re #14404
---
 Framework/Kernel/src/ConfigService.cpp | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/Framework/Kernel/src/ConfigService.cpp b/Framework/Kernel/src/ConfigService.cpp
index 52cd4700d45..9b3107e78d6 100644
--- a/Framework/Kernel/src/ConfigService.cpp
+++ b/Framework/Kernel/src/ConfigService.cpp
@@ -255,10 +255,27 @@ ConfigServiceImpl::ConfigServiceImpl()
   Poco::Path path(appDataDir);
   path.pushDirectory("instrument");
   Poco::File file(path);
-  // createdirectories will fail gracefully if it is already present
-  file.createDirectories();
+  // createDirectories will fail gracefully if it is already present - but will
+  // throw an error if it cannot create the directory
+  try {
+    file.createDirectories();
+  } catch (Poco::FileException &fe) {
+    g_log.error()
+        << "Cannot create the local instrument cache directory ["
+        << path.toString()
+        << "]. Mantid will not be able to update instrument definitions.\n"
+        << fe.what() << std::endl;
+  }
   Poco::File vtpDir(getVTPFileDirectory());
-  vtpDir.createDirectories();
+  try {
+    vtpDir.createDirectories();
+  } catch (Poco::FileException &fe) {
+    g_log.error()
+        << "Cannot create the local instrument geometry cache directory ["
+        << path.toString()
+        << "]. Mantid will be slower at viewing complex instruments.\n"
+        << fe.what() << std::endl;
+  }
   // must update the cache of instrument paths
   cacheInstrumentPaths();
 }
-- 
GitLab