From a46c088d0c1be94a51738e10ecdea9e115ef34c4 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 19 Mar 2014 11:00:32 +1100 Subject: [PATCH] Ensures correct exceptions are thrown when configurations cannot be loaded, before was just null ref exception which was not good. --- src/Umbraco.Core/Configuration/UmbracoConfig.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Core/Configuration/UmbracoConfig.cs b/src/Umbraco.Core/Configuration/UmbracoConfig.cs index 27fb572300..d0d835f22a 100644 --- a/src/Umbraco.Core/Configuration/UmbracoConfig.cs +++ b/src/Umbraco.Core/Configuration/UmbracoConfig.cs @@ -37,7 +37,10 @@ namespace Umbraco.Core.Configuration var umbracoSettings = ConfigurationManager.GetSection("umbracoConfiguration/settings") as IUmbracoSettingsSection; if (umbracoSettings == null) { - LogHelper.Warn("Could not load the " + typeof(IUmbracoSettingsSection) + " from config file!"); + var ex = new ConfigurationErrorsException("Could not load the " + typeof (IUmbracoSettingsSection) + " from config file, ensure the web.config and umbracoSettings.config files are formatted correctly"); + LogHelper.Error("Could not load umbracoSettings.config", ex); + throw ex; + } SetUmbracoSettings(umbracoSettings); } @@ -47,7 +50,9 @@ namespace Umbraco.Core.Configuration var baseRestExtensions = ConfigurationManager.GetSection("umbracoConfiguration/BaseRestExtensions") as IBaseRestSection; if (baseRestExtensions == null) { - LogHelper.Warn("Could not load the " + typeof(IBaseRestSection) + " from config file!"); + var ex = new ConfigurationErrorsException("Could not load the " + typeof(IBaseRestSection) + " from config file, ensure the web.config and BaseRestExtensions.config files are formatted correctly"); + LogHelper.Error("Could not load BaseRestExtensions.config", ex); + throw ex; } SetBaseRestExtensions(baseRestExtensions); } @@ -57,7 +62,9 @@ namespace Umbraco.Core.Configuration var dashboardConfig = ConfigurationManager.GetSection("umbracoConfiguration/dashBoard") as IDashboardSection; if (dashboardConfig == null) { - LogHelper.Warn("Could not load the " + typeof(IDashboardSection) + " from config file!"); + var ex = new ConfigurationErrorsException("Could not load the " + typeof(IDashboardSection) + " from config file, ensure the web.config and Dashboard.config files are formatted correctly"); + LogHelper.Error("Could not load Dashboard.config", ex); + throw ex; } SetDashboardSettings(dashboardConfig); }