mirror of https://github.com/Radarr/Radarr
Display a better error message when config.xml is corrupt
This commit is contained in:
parent
56f695577c
commit
92cc41edeb
|
@ -140,7 +140,7 @@ namespace NzbDrone.Core.Configuration
|
|||
{
|
||||
EnsureDefaultConfigFile();
|
||||
|
||||
var xDoc = XDocument.Load(_configFile);
|
||||
var xDoc = LoadConfigFile();
|
||||
var config = xDoc.Descendants(CONFIG_ELEMENT_NAME).Single();
|
||||
|
||||
var parentContainer = config;
|
||||
|
@ -162,7 +162,7 @@ namespace NzbDrone.Core.Configuration
|
|||
{
|
||||
EnsureDefaultConfigFile();
|
||||
|
||||
var xDoc = XDocument.Load(_configFile);
|
||||
var xDoc = LoadConfigFile();
|
||||
var config = xDoc.Descendants(CONFIG_ELEMENT_NAME).Single();
|
||||
|
||||
var parentContainer = config;
|
||||
|
@ -203,7 +203,7 @@ namespace NzbDrone.Core.Configuration
|
|||
{
|
||||
EnsureDefaultConfigFile();
|
||||
|
||||
var xDoc = XDocument.Load(_configFile);
|
||||
var xDoc = LoadConfigFile();
|
||||
var config = xDoc.Descendants(CONFIG_ELEMENT_NAME).Single();
|
||||
|
||||
var type = GetType();
|
||||
|
@ -222,6 +222,19 @@ namespace NzbDrone.Core.Configuration
|
|||
xDoc.Save(_configFile);
|
||||
}
|
||||
|
||||
private XDocument LoadConfigFile()
|
||||
{
|
||||
try
|
||||
{
|
||||
return XDocument.Load(_configFile);
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new InvalidConfigFileException("config.xml is invalid, please see the wiki for steps to resolve this issue.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void HandleAsync(ApplicationStartedEvent message)
|
||||
{
|
||||
DeleteOldValues();
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using NzbDrone.Common.Exceptions;
|
||||
|
||||
namespace NzbDrone.Core.Configuration
|
||||
{
|
||||
public class InvalidConfigFileException : Exception
|
||||
{
|
||||
public InvalidConfigFileException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -123,6 +123,7 @@
|
|||
<Compile Include="Configuration\Events\ConfigFileSavedEvent.cs" />
|
||||
<Compile Include="Configuration\Events\ConfigSavedEvent.cs" />
|
||||
<Compile Include="Configuration\IConfigService.cs" />
|
||||
<Compile Include="Configuration\InvalidConfigFileException.cs" />
|
||||
<Compile Include="DataAugmentation\DailySeries\DailySeriesDataProxy.cs" />
|
||||
<Compile Include="DataAugmentation\DailySeries\DailySeriesService.cs" />
|
||||
<Compile Include="DataAugmentation\Scene\SceneMapping.cs" />
|
||||
|
|
Loading…
Reference in New Issue