Ensures correct exceptions are thrown when configurations cannot be loaded, before was just null ref exception which was not good.

This commit is contained in:
Shannon
2014-03-19 11:00:32 +11:00
parent 65e591501c
commit a46c088d0c

View File

@@ -37,7 +37,10 @@ namespace Umbraco.Core.Configuration
var umbracoSettings = ConfigurationManager.GetSection("umbracoConfiguration/settings") as IUmbracoSettingsSection;
if (umbracoSettings == null)
{
LogHelper.Warn<UmbracoConfig>("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<UmbracoConfig>("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<UmbracoConfig>("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<UmbracoConfig>("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<UmbracoConfig>("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<UmbracoConfig>("Could not load Dashboard.config", ex);
throw ex;
}
SetDashboardSettings(dashboardConfig);
}