Skip to content

Commit

Permalink
misc: add path and/or other details when throwing
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
revam committed Sep 22, 2024
1 parent 70bfe17 commit 5ea5cb1
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Shokofin/Providers/BoxSetProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public async Task<MetadataResult<BoxSet>> 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<BoxSet>();
}
}
Expand Down
10 changes: 9 additions & 1 deletion Shokofin/Providers/EpisodeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,15 @@ public async Task<MetadataResult<Episode>> 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<Episode>();
}
finally {
Expand Down
2 changes: 1 addition & 1 deletion Shokofin/Providers/MovieProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public async Task<MetadataResult<Movie>> 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<Movie>();
}
finally {
Expand Down
2 changes: 1 addition & 1 deletion Shokofin/Providers/SeasonProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public async Task<MetadataResult<Season>> 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<Season>();
}
finally {
Expand Down
2 changes: 1 addition & 1 deletion Shokofin/Providers/SeriesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public async Task<MetadataResult<Series>> 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<Series>();
}
finally {
Expand Down
2 changes: 1 addition & 1 deletion Shokofin/Providers/TrailerProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public async Task<MetadataResult<Trailer>> 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<Trailer>();
}
finally {
Expand Down
2 changes: 1 addition & 1 deletion Shokofin/Providers/VideoProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public async Task<MetadataResult<Video>> 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<Video>();
}
finally {
Expand Down

0 comments on commit 5ea5cb1

Please sign in to comment.