From c867eb3250d66b788758c295fcd9b11d999fdc8e Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Tue, 11 Nov 2014 16:55:44 -0800 Subject: [PATCH] Prevent crash when constructor for an Editor throws an exception --- .../Common/Reflection.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/Common/Reflection.cs b/CSharp/Libraries/UniversalEditor.UserInterface/Common/Reflection.cs index 42d96ef1..0028ae8a 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/Common/Reflection.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface/Common/Reflection.cs @@ -59,6 +59,10 @@ namespace UniversalEditor.UserInterface.Common { Console.WriteLine("binding error: " + ex.InnerException.Message); } + catch (Exception ex) + { + Console.WriteLine("error while loading editor '" + type.FullName + "': " + ex.Message); + } break; } #endregion @@ -69,11 +73,15 @@ namespace UniversalEditor.UserInterface.Common { IOptionPanelImplementation editor = (type.Assembly.CreateInstance(type.FullName) as IOptionPanelImplementation); listOptionPanels.Add(editor); - } - catch (System.Reflection.TargetInvocationException ex) - { - throw ex.InnerException; - } + } + catch (System.Reflection.TargetInvocationException ex) + { + Console.WriteLine("binding error: " + ex.InnerException.Message); + } + catch (Exception ex) + { + Console.WriteLine("error while loading editor '" + type.FullName + "': " + ex.Message); + } break; } #endregion