diff --git a/src/Umbraco.Core/CoreBootManager.cs b/src/Umbraco.Core/CoreBootManager.cs index 740df8015d..5020086700 100644 --- a/src/Umbraco.Core/CoreBootManager.cs +++ b/src/Umbraco.Core/CoreBootManager.cs @@ -97,7 +97,18 @@ namespace Umbraco.Core //now we need to call the initialize methods ApplicationEventsResolver.Current.ApplicationEventHandlers - .ForEach(x => x.OnApplicationInitialized(UmbracoApplication, ApplicationContext)); + .ForEach(x => + { + try + { + x.OnApplicationInitialized(UmbracoApplication, ApplicationContext); + } + catch (Exception ex) + { + LogHelper.Error("An error occurred running OnApplicationInitialized for handler " + x.GetType(), ex); + throw; + } + }); _isInitialized = true; @@ -203,7 +214,18 @@ namespace Umbraco.Core //call OnApplicationStarting of each application events handler ApplicationEventsResolver.Current.ApplicationEventHandlers - .ForEach(x => x.OnApplicationStarting(UmbracoApplication, ApplicationContext)); + .ForEach(x => + { + try + { + x.OnApplicationStarting(UmbracoApplication, ApplicationContext); + } + catch (Exception ex) + { + LogHelper.Error("An error occurred running OnApplicationStarting for handler " + x.GetType(), ex); + throw; + } + }); if (afterStartup != null) { @@ -229,7 +251,18 @@ namespace Umbraco.Core //call OnApplicationStarting of each application events handler ApplicationEventsResolver.Current.ApplicationEventHandlers - .ForEach(x => x.OnApplicationStarted(UmbracoApplication, ApplicationContext)); + .ForEach(x => + { + try + { + x.OnApplicationStarted(UmbracoApplication, ApplicationContext); + } + catch (Exception ex) + { + LogHelper.Error("An error occurred running OnApplicationStarted for handler " + x.GetType(), ex); + throw; + } + }); //Now, startup all of our legacy startup handler ApplicationEventsResolver.Current.InstantiateLegacyStartupHandlers(); diff --git a/src/Umbraco.Core/PluginManager.cs b/src/Umbraco.Core/PluginManager.cs index d03edc0fc6..c63d8cdfde 100644 --- a/src/Umbraco.Core/PluginManager.cs +++ b/src/Umbraco.Core/PluginManager.cs @@ -606,14 +606,10 @@ namespace Umbraco.Core /// internal IEnumerable CreateInstances(IEnumerable types, bool throwException = false) { - //Have removed logging because it doesn't really need to be logged since the time taken is generally 0ms. - //we want to know if it fails ever, not how long it took if it is only 0. - var typesAsArray = types.ToArray(); - //using (DisposableTimer.DebugDuration( - // String.Format("Starting instantiation of {0} objects of type {1}", typesAsArray.Length, typeof(T).FullName), - // String.Format("Completed instantiation of {0} objects of type {1}", typesAsArray.Length, typeof(T).FullName))) - //{ + + LogHelper.Debug(string.Format("Instantiating {0} objects of type {1}", typesAsArray.Length, typeof (T).FullName)); + var instances = new List(); foreach (var t in typesAsArray) { @@ -634,7 +630,7 @@ namespace Umbraco.Core } } return instances; - //} + } /// diff --git a/src/Umbraco.Core/UmbracoApplicationBase.cs b/src/Umbraco.Core/UmbracoApplicationBase.cs index c861eca6cd..07e3a6bbf3 100644 --- a/src/Umbraco.Core/UmbracoApplicationBase.cs +++ b/src/Umbraco.Core/UmbracoApplicationBase.cs @@ -73,7 +73,18 @@ namespace Umbraco.Core protected virtual void OnApplicationStarting(object sender, EventArgs e) { if (ApplicationStarting != null) - ApplicationStarting(sender, e); + { + try + { + ApplicationStarting(sender, e); + } + catch (Exception ex) + { + LogHelper.Error("An error occurred in an ApplicationStarting event handler", ex); + throw; + } + } + } /// @@ -84,7 +95,17 @@ namespace Umbraco.Core protected virtual void OnApplicationStarted(object sender, EventArgs e) { if (ApplicationStarted != null) - ApplicationStarted(sender, e); + { + try + { + ApplicationStarted(sender, e); + } + catch (Exception ex) + { + LogHelper.Error("An error occurred in an ApplicationStarted event handler", ex); + throw; + } + } } /// @@ -95,7 +116,17 @@ namespace Umbraco.Core private void OnApplicationInit(object sender, EventArgs e) { if (ApplicationInit != null) - ApplicationInit(sender, e); + { + try + { + ApplicationInit(sender, e); + } + catch (Exception ex) + { + LogHelper.Error("An error occurred in an ApplicationInit event handler", ex); + throw; + } + } } ///