From ae4564a3446e10178ee89c2ef888bdd6547001c4 Mon Sep 17 00:00:00 2001
From: Giovanni Di Siena <giodisiena@gmail.com>
Date: Fri, 1 Nov 2019 10:54:29 +0000
Subject: [PATCH] Catch unhandled exceptions

Re #27178
---
 .../GUI/MainWindow/MainWindowPresenter.cpp            | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.cpp
index 38e8863befe..853e37d820a 100644
--- a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.cpp
+++ b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.cpp
@@ -20,6 +20,7 @@
 #include "Reduction/Batch.h"
 
 #include <QFileDialog>
+#include <QMessageBox>
 
 namespace MantidQt {
 namespace CustomInterfaces {
@@ -195,7 +196,15 @@ void MainWindowPresenter::notifyLoadBatchRequested(int tabIndex) {
   auto filename = QFileDialog::getOpenFileName();
   if (filename == "")
     return;
-  auto map = MantidQt::API::loadJSONFromFile(filename);
+  QMap<QString, QVariant> map;
+  try {
+    map = MantidQt::API::loadJSONFromFile(filename);
+  } catch (const std::runtime_error &e) {
+    QMessageBox msgBox;
+    msgBox.setText("Unable to load requested file. Please load a file of "
+                   "appropriate format saved from the GUI.");
+    msgBox.exec();
+  }
   IBatchPresenter *batchPresenter = m_batchPresenters[tabIndex].get();
   Decoder decoder;
   decoder.decodeBatch(batchPresenter, m_view, map);
-- 
GitLab