mirror of
https://github.com/Radarr/Radarr
synced 2024-12-26 09:49:00 +00:00
Display a better error message when config.xml is corrupt
This commit is contained in:
parent
56f695577c
commit
92cc41edeb
3 changed files with 32 additions and 3 deletions
|
@ -140,7 +140,7 @@ public string GetValue(string key, object defaultValue)
|
|||
{
|
||||
EnsureDefaultConfigFile();
|
||||
|
||||
var xDoc = XDocument.Load(_configFile);
|
||||
var xDoc = LoadConfigFile();
|
||||
var config = xDoc.Descendants(CONFIG_ELEMENT_NAME).Single();
|
||||
|
||||
var parentContainer = config;
|
||||
|
@ -162,7 +162,7 @@ public void SetValue(string key, object value)
|
|||
{
|
||||
EnsureDefaultConfigFile();
|
||||
|
||||
var xDoc = XDocument.Load(_configFile);
|
||||
var xDoc = LoadConfigFile();
|
||||
var config = xDoc.Descendants(CONFIG_ELEMENT_NAME).Single();
|
||||
|
||||
var parentContainer = config;
|
||||
|
@ -203,7 +203,7 @@ private void DeleteOldValues()
|
|||
{
|
||||
EnsureDefaultConfigFile();
|
||||
|
||||
var xDoc = XDocument.Load(_configFile);
|
||||
var xDoc = LoadConfigFile();
|
||||
var config = xDoc.Descendants(CONFIG_ELEMENT_NAME).Single();
|
||||
|
||||
var type = GetType();
|
||||
|
@ -222,6 +222,19 @@ private void DeleteOldValues()
|
|||
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();
|
||||
|
|
15
NzbDrone.Core/Configuration/InvalidConfigFileException.cs
Normal file
15
NzbDrone.Core/Configuration/InvalidConfigFileException.cs
Normal file
|
@ -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 a new issue