From e6924c10e4c7c4863a451ff6c8a2c2febccc7191 Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Mon, 7 Aug 2023 17:00:48 -0500 Subject: [PATCH] fix: Better error message when no config files are found --- CHANGELOG.md | 4 ++++ .../Console/Commands/ConfigListCommand.cs | 5 +++++ src/Recyclarr.Cli/Processors/Sync/SyncProcessor.cs | 7 ++++++- .../ErrorHandling/NoConfigurationFilesException.cs | 12 ------------ 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d4cd417..5c6aed46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Reduce the time it takes to clone the config and trash repositories by performing shallow clones (#201). +### Fixed + +- Better error message to console when no configuration files are found. + ## [5.2.0] - 2023-08-06 ### Added diff --git a/src/Recyclarr.Cli/Console/Commands/ConfigListCommand.cs b/src/Recyclarr.Cli/Console/Commands/ConfigListCommand.cs index 1c515e7d..105b495b 100644 --- a/src/Recyclarr.Cli/Console/Commands/ConfigListCommand.cs +++ b/src/Recyclarr.Cli/Console/Commands/ConfigListCommand.cs @@ -4,6 +4,7 @@ using JetBrains.Annotations; using Recyclarr.Cli.Console.Helpers; using Recyclarr.Cli.Processors.Config; using Recyclarr.TrashLib.Config.Listers; +using Recyclarr.TrashLib.Config.Parsing.ErrorHandling; using Recyclarr.TrashLib.ExceptionTypes; using Spectre.Console.Cli; @@ -45,6 +46,10 @@ public class ConfigListCommand : AsyncCommand return 1; } + catch (NoConfigurationFilesException) + { + _log.Error("No configuration files found"); + } return 0; } diff --git a/src/Recyclarr.Cli/Processors/Sync/SyncProcessor.cs b/src/Recyclarr.Cli/Processors/Sync/SyncProcessor.cs index 67d04ae7..914667a3 100644 --- a/src/Recyclarr.Cli/Processors/Sync/SyncProcessor.cs +++ b/src/Recyclarr.Cli/Processors/Sync/SyncProcessor.cs @@ -6,6 +6,7 @@ using Recyclarr.Common.Extensions; using Recyclarr.TrashLib.Compatibility; using Recyclarr.TrashLib.Config; using Recyclarr.TrashLib.Config.Parsing; +using Recyclarr.TrashLib.Config.Parsing.ErrorHandling; using Recyclarr.TrashLib.Config.Services; using Recyclarr.TrashLib.Http; using Recyclarr.TrashLib.Repo.VersionControl; @@ -129,6 +130,10 @@ public class SyncProcessor : ISyncProcessor break; + case NoConfigurationFilesException: + _log.Error("No configuration files found"); + break; + default: throw e; } @@ -143,7 +148,7 @@ public class SyncProcessor : ISyncProcessor } return response - .Select(x => (string)x.errorMessage) + .Select(x => (string) x.errorMessage) .NotNull(x => !string.IsNullOrEmpty(x)) .ToList(); } diff --git a/src/Recyclarr.TrashLib/Config/Parsing/ErrorHandling/NoConfigurationFilesException.cs b/src/Recyclarr.TrashLib/Config/Parsing/ErrorHandling/NoConfigurationFilesException.cs index 7de9967a..8fb3a98e 100644 --- a/src/Recyclarr.TrashLib/Config/Parsing/ErrorHandling/NoConfigurationFilesException.cs +++ b/src/Recyclarr.TrashLib/Config/Parsing/ErrorHandling/NoConfigurationFilesException.cs @@ -1,17 +1,5 @@ -using System.Runtime.Serialization; - namespace Recyclarr.TrashLib.Config.Parsing.ErrorHandling; -[Serializable] public class NoConfigurationFilesException : Exception { - public NoConfigurationFilesException() - : base("No configuration YAML files found") - { - } - - protected NoConfigurationFilesException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } }