From 5ea5cb192c2ca68bc224d0dd4e66f63493f0ef23 Mon Sep 17 00:00:00 2001 From: Mikal Stordal Date: Mon, 23 Sep 2024 01:21:33 +0200 Subject: [PATCH] misc: add path and/or other details when throwing - Added the path and/or other details when throwing in a provider, to more easily identify _which_ series/episode is throwing if the stack trace and/or error message is generic/useless. --- Shokofin/Providers/BoxSetProvider.cs | 2 +- Shokofin/Providers/EpisodeProvider.cs | 10 +++++++++- Shokofin/Providers/MovieProvider.cs | 2 +- Shokofin/Providers/SeasonProvider.cs | 2 +- Shokofin/Providers/SeriesProvider.cs | 2 +- Shokofin/Providers/TrailerProvider.cs | 2 +- Shokofin/Providers/VideoProvider.cs | 2 +- 7 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Shokofin/Providers/BoxSetProvider.cs b/Shokofin/Providers/BoxSetProvider.cs index 41e1fd7c..381443af 100644 --- a/Shokofin/Providers/BoxSetProvider.cs +++ b/Shokofin/Providers/BoxSetProvider.cs @@ -50,7 +50,7 @@ public async Task> GetMetadata(BoxSetInfo info, Cancellat return new(); } catch (Exception ex) { - Logger.LogError(ex, "Threw unexpectedly; {Message}", ex.Message); + Logger.LogError(ex, "Threw unexpectedly while refreshing {Path}; {Message}", info.Path, ex.Message); return new MetadataResult(); } } diff --git a/Shokofin/Providers/EpisodeProvider.cs b/Shokofin/Providers/EpisodeProvider.cs index 10a7caa0..67779204 100644 --- a/Shokofin/Providers/EpisodeProvider.cs +++ b/Shokofin/Providers/EpisodeProvider.cs @@ -86,7 +86,15 @@ public async Task> GetMetadata(EpisodeInfo info, Cancell return result; } catch (Exception ex) { - Logger.LogError(ex, "Threw unexpectedly; {Message}", ex.Message); + if (info.IsMissingEpisode || string.IsNullOrEmpty(info.Path)) { + if (!info.TryGetProviderId(ShokoEpisodeId.Name, out var episodeId)) + episodeId = null; + Logger.LogError(ex, "Threw unexpectedly while refreshing a missing episode; {Message} (Episode={EpisodeId})", ex.Message, episodeId); + } + else { + Logger.LogError(ex, "Threw unexpectedly while refreshing {Path}: {Message}", info.Path, info.IsMissingEpisode); + } + return new MetadataResult(); } finally { diff --git a/Shokofin/Providers/MovieProvider.cs b/Shokofin/Providers/MovieProvider.cs index 6c598e5e..03a5213e 100644 --- a/Shokofin/Providers/MovieProvider.cs +++ b/Shokofin/Providers/MovieProvider.cs @@ -83,7 +83,7 @@ public async Task> GetMetadata(MovieInfo info, Cancellatio return result; } catch (Exception ex) { - Logger.LogError(ex, "Threw unexpectedly; {Message}", ex.Message); + Logger.LogError(ex, "Threw unexpectedly while refreshing {Path}; {Message}", info.Path, ex.Message); return new MetadataResult(); } finally { diff --git a/Shokofin/Providers/SeasonProvider.cs b/Shokofin/Providers/SeasonProvider.cs index 4f145a38..a16e55f8 100644 --- a/Shokofin/Providers/SeasonProvider.cs +++ b/Shokofin/Providers/SeasonProvider.cs @@ -91,7 +91,7 @@ public async Task> GetMetadata(SeasonInfo info, Cancellat return result; } catch (Exception ex) { - Logger.LogError(ex, "Threw unexpectedly; {Message}", ex.Message); + Logger.LogError(ex, "Threw unexpectedly while refreshing season {SeasonNumber}; {Message} (Path={Path},Series={SeriesId})", info.IndexNumber, ex.Message, info.Path, seriesId); return new MetadataResult(); } finally { diff --git a/Shokofin/Providers/SeriesProvider.cs b/Shokofin/Providers/SeriesProvider.cs index de045382..ef468ae5 100644 --- a/Shokofin/Providers/SeriesProvider.cs +++ b/Shokofin/Providers/SeriesProvider.cs @@ -95,7 +95,7 @@ public async Task> GetMetadata(SeriesInfo info, Cancellat return result; } catch (Exception ex) { - Logger.LogError(ex, "Threw unexpectedly; {Message}", ex.Message); + Logger.LogError(ex, "Threw unexpectedly while refreshing {Path}; {Message}", info.Path, ex.Message); return new MetadataResult(); } finally { diff --git a/Shokofin/Providers/TrailerProvider.cs b/Shokofin/Providers/TrailerProvider.cs index 22d6eefd..14de6862 100644 --- a/Shokofin/Providers/TrailerProvider.cs +++ b/Shokofin/Providers/TrailerProvider.cs @@ -68,7 +68,7 @@ public async Task> GetMetadata(TrailerInfo info, Cancell return result; } catch (Exception ex) { - Logger.LogError(ex, "Threw unexpectedly; {Message}", ex.Message); + Logger.LogError(ex, "Threw unexpectedly while refreshing path {Path}; {Message}", info.Path, ex.Message); return new MetadataResult(); } finally { diff --git a/Shokofin/Providers/VideoProvider.cs b/Shokofin/Providers/VideoProvider.cs index cafd8897..3581d970 100644 --- a/Shokofin/Providers/VideoProvider.cs +++ b/Shokofin/Providers/VideoProvider.cs @@ -68,7 +68,7 @@ public async Task> GetMetadata(ItemLookupInfo info, Cancel return result; } catch (Exception ex) { - Logger.LogError(ex, "Threw unexpectedly; {Message}", ex.Message); + Logger.LogError(ex, "Threw unexpectedly while refreshing {Path}; {Message}", info.Path, ex.Message); return new MetadataResult