Prevent crash when constructor for an Editor throws an exception

This commit is contained in:
Michael Becker 2014-11-11 16:55:44 -08:00
parent 50ca3678e7
commit c867eb3250

View File

@ -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