From 991cde070c10dda93e12ca29a43a7fdff01bcb9d Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Thu, 23 Jan 2020 03:38:40 -0500 Subject: [PATCH] also catch InvalidDataFormatException because let's be honest, there's nothing we can do at that point --- .../MainWindow.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/MainWindow.cs b/CSharp/Libraries/UniversalEditor.UserInterface/MainWindow.cs index ef713f50..b349260b 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/MainWindow.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface/MainWindow.cs @@ -527,6 +527,28 @@ namespace UniversalEditor.UserInterface } return; } + catch (InvalidDataFormatException ex) + { + // we're catching this one because there's nothing anyone (not even the developer) can do about it if the DF throws ObjectModelNotSupported + DialogResult result = MessageDialog.ShowDialog("The data format you specified could not load the file.", "Error", MessageDialogButtons.RetryCancel, MessageDialogIcon.Error); + if (result == DialogResult.Retry) + { + DocumentPropertiesDialog dlg = new DocumentPropertiesDialog(); + dlg.DataFormat = doc.DataFormat; + dlg.ObjectModel = doc.ObjectModel; + dlg.Accessor = doc.Accessor; + if (dlg.ShowDialog() == DialogResult.OK) + { + doc.DataFormat = dlg.DataFormat; + doc.ObjectModel = dlg.ObjectModel; + doc.Accessor = dlg.Accessor; + } + + // try loading it again + continue; + } + return; + } catch (Exception ex) { if (!System.Diagnostics.Debugger.IsAttached)