From a24cb40a6e3cc970c970ced537f06093fffd5917 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Sat, 4 Jan 2020 20:57:34 -0500 Subject: [PATCH] don't swallow all exceptions if debugger is attached; we probably want to debug them. but special case ObjectModelNotSupported since we can't do anything about that --- .../MainWindow.cs | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/MainWindow.cs b/CSharp/Libraries/UniversalEditor.UserInterface/MainWindow.cs index 7c1d795a..c40ce5c7 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/MainWindow.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface/MainWindow.cs @@ -515,10 +515,27 @@ namespace UniversalEditor.UserInterface doc.IsSaved = true; loaded = true; } + catch (ObjectModelNotSupportedException 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 object model you specified is not supported by the selected DataFormat.", "Error", MessageDialogButtons.RetryCancel, MessageDialogIcon.Error); + if (result == DialogResult.Retry) + { + } + return; + } catch (Exception ex) { - MessageDialog.ShowDialog("could not load file: " + ex.GetType().Name + "\r\n" + ex.Message, "Error", MessageDialogButtons.OK, MessageDialogIcon.Error); - return; + if (!System.Diagnostics.Debugger.IsAttached) + { + MessageDialog.ShowDialog("could not load file: " + ex.GetType().Name + "\r\n" + ex.Message, "Error", MessageDialogButtons.OK, MessageDialogIcon.Error); + return; + } + else + { + // fk it + throw ex; + } } } else @@ -698,7 +715,7 @@ namespace UniversalEditor.UserInterface }, DragDropEffect.Copy, MouseButtons.Primary | MouseButtons.Secondary, KeyboardModifierKey.None); } - #region IHostApplicationWindow implementation +#region IHostApplicationWindow implementation public void OpenFile() { /* @@ -1255,7 +1272,7 @@ namespace UniversalEditor.UserInterface } } - #endregion +#endregion public void ShowDocumentPropertiesDialog()