diff --git a/src/NzbDrone.Host/Bootstrap.cs b/src/NzbDrone.Host/Bootstrap.cs index c72b07dcb..c9ede9d05 100644 --- a/src/NzbDrone.Host/Bootstrap.cs +++ b/src/NzbDrone.Host/Bootstrap.cs @@ -198,10 +198,19 @@ namespace NzbDrone.Host private static IConfiguration GetConfiguration(StartupContext context) { var appFolder = new AppFolderInfo(context); - return new ConfigurationBuilder() - .AddXmlFile(appFolder.GetConfigPath(), optional: true, reloadOnChange: false) - .AddInMemoryCollection(new List> { new ("dataProtectionFolder", appFolder.GetDataProtectionPath()) }) - .Build(); + var configPath = appFolder.GetConfigPath(); + + try + { + return new ConfigurationBuilder() + .AddXmlFile(configPath, optional: true, reloadOnChange: false) + .AddInMemoryCollection(new List> { new ("dataProtectionFolder", appFolder.GetDataProtectionPath()) }) + .Build(); + } + catch (InvalidDataException ex) + { + throw new InvalidConfigFileException($"{configPath} is corrupt or invalid. Please delete the config file and Sonarr will recreate it.", ex); + } } private static string BuildUrl(string scheme, string bindAddress, int port)