From 01d7f570fa4ee9b0f77dd6de1b2222921821f5d5 Mon Sep 17 00:00:00 2001 From: ConfusedPolarBear <33811686+ConfusedPolarBear@users.noreply.github.com> Date: Sun, 12 Jun 2022 16:08:31 -0500 Subject: [PATCH] Catch any exception thrown during plugin startup --- .../Entrypoint.cs | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs index a1f2cc4..3aac306 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs @@ -58,23 +58,30 @@ public class Entrypoint : IServerEntryPoint return Task.CompletedTask; } - // As soon as a new episode is added, queue it for later analysis. - _libraryManager.ItemAdded += ItemAdded; - - // For all TV show libraries, enqueue all contained items. - foreach (var folder in _libraryManager.GetVirtualFolders()) + try { - if (folder.CollectionType != CollectionTypeOptions.TvShows) + // As soon as a new episode is added, queue it for later analysis. + _libraryManager.ItemAdded += ItemAdded; + + // For all TV show libraries, enqueue all contained items. + foreach (var folder in _libraryManager.GetVirtualFolders()) { - continue; + if (folder.CollectionType != CollectionTypeOptions.TvShows) + { + continue; + } + + _logger.LogInformation( + "Running startup enqueue of items in library {Name} ({ItemId})", + folder.Name, + folder.ItemId); + + QueueLibraryContents(folder.ItemId); } - - _logger.LogInformation( - "Running startup enqueue of items in library {Name} ({ItemId})", - folder.Name, - folder.ItemId); - - QueueLibraryContents(folder.ItemId); + } + catch (Exception ex) + { + _logger.LogError("Unable to run startup enqueue: {Exception}", ex); } return Task.CompletedTask;