refactor: Deprecation messages for old style array mapping

pull/201/head
Robert Dailey 2 years ago
parent 76040df597
commit 286f4b95b1

@ -0,0 +1,18 @@
using YamlDotNet.Core;
namespace Recyclarr.TrashLib.Config.Parsing;
public static class ConfigDeprecations
{
public static string? GetContextualErrorFromException(YamlException e)
{
if (e.Message.Contains("Expected 'MappingStart', got 'SequenceStart'"))
{
return "Found array-style list of instances instead of named-style. " +
"Array-style lists of Sonarr/Radarr instances are not supported. " +
"See: https://recyclarr.dev/wiki/upgrade-guide/v5.0/#instances-must-now-be-named";
}
return null;
}
}

@ -58,6 +58,8 @@ public class ConfigParser
}
catch (YamlException e)
{
_log.Debug(e, "Exception while parsing config file");
var line = e.Start.Line;
switch (e.InnerException)
{
@ -67,7 +69,11 @@ public class ConfigParser
break;
default:
_log.Error("Exception at line {Line}: {Msg}", line, e.InnerException?.Message ?? e.Message);
// Check for Configuration-specific deprecation messages
var msg = ConfigDeprecations.GetContextualErrorFromException(e) ??
e.InnerException?.Message ?? e.Message;
_log.Error("Exception at line {Line}: {Msg}", line, msg);
break;
}

Loading…
Cancel
Save