diff --git a/ErsatzTV.Application/Channels/Queries/GetChannelFramerateHandler.cs b/ErsatzTV.Application/Channels/Queries/GetChannelFramerateHandler.cs index 6f13bff95..89e2c9217 100644 --- a/ErsatzTV.Application/Channels/Queries/GetChannelFramerateHandler.cs +++ b/ErsatzTV.Application/Channels/Queries/GetChannelFramerateHandler.cs @@ -86,10 +86,20 @@ public class GetChannelFramerateHandler : IRequestHandler return BaseError.New($"ErsatzTV.Scanner exited with code {process.ExitCode}"); } } - catch (OperationCanceledException) + catch (Exception ex) when (ex is TaskCanceledException or OperationCanceledException) { // do nothing } diff --git a/ErsatzTV.Application/Streaming/HlsSessionWorker.cs b/ErsatzTV.Application/Streaming/HlsSessionWorker.cs index 36e4395d1..736bed945 100644 --- a/ErsatzTV.Application/Streaming/HlsSessionWorker.cs +++ b/ErsatzTV.Application/Streaming/HlsSessionWorker.cs @@ -67,31 +67,38 @@ public class HlsSessionWorker : IHlsSessionWorker DateTimeOffset filterBefore, CancellationToken cancellationToken) { - var sw = Stopwatch.StartNew(); - await Slim.WaitAsync(cancellationToken); try { - Option maybeLines = await ReadPlaylistLines(cancellationToken); - foreach (string[] input in maybeLines) + var sw = Stopwatch.StartNew(); + await Slim.WaitAsync(cancellationToken); + try { - TrimPlaylistResult trimResult = _hlsPlaylistFilter.TrimPlaylist(PlaylistStart, filterBefore, input); - if (DateTimeOffset.Now > _lastDelete.AddSeconds(30)) + Option maybeLines = await ReadPlaylistLines(cancellationToken); + foreach (string[] input in maybeLines) { - DeleteOldSegments(trimResult); - _lastDelete = DateTimeOffset.Now; + TrimPlaylistResult trimResult = _hlsPlaylistFilter.TrimPlaylist(PlaylistStart, filterBefore, input); + if (DateTimeOffset.Now > _lastDelete.AddSeconds(30)) + { + DeleteOldSegments(trimResult); + _lastDelete = DateTimeOffset.Now; + } + + return trimResult; } - - return trimResult; } - - return None; + finally + { + Slim.Release(); + sw.Stop(); + // _logger.LogDebug("TrimPlaylist took {Duration}", sw.Elapsed); + } } - finally + catch (Exception ex) when (ex is TaskCanceledException or OperationCanceledException) { - Slim.Release(); - sw.Stop(); - // _logger.LogDebug("TrimPlaylist took {Duration}", sw.Elapsed); + // do nothing } + + return None; } public void PlayoutUpdated() diff --git a/ErsatzTV.Infrastructure/Emby/EmbyApiClient.cs b/ErsatzTV.Infrastructure/Emby/EmbyApiClient.cs index 8d35c6d50..cf8db0a30 100644 --- a/ErsatzTV.Infrastructure/Emby/EmbyApiClient.cs +++ b/ErsatzTV.Infrastructure/Emby/EmbyApiClient.cs @@ -39,7 +39,7 @@ public class EmbyApiClient : IEmbyApiClient return await service.GetSystemInformation(apiKey, cts.Token) .Map(response => new EmbyServerInformation(response.ServerName, response.OperatingSystem)); } - catch (OperationCanceledException ex) + catch (Exception ex) when (ex is TaskCanceledException or OperationCanceledException) { _logger.LogError(ex, "Timeout getting emby server name"); return BaseError.New("Emby did not respond in time"); diff --git a/ErsatzTV.Infrastructure/Jellyfin/JellyfinApiClient.cs b/ErsatzTV.Infrastructure/Jellyfin/JellyfinApiClient.cs index 5b90f6630..cfc31eb61 100644 --- a/ErsatzTV.Infrastructure/Jellyfin/JellyfinApiClient.cs +++ b/ErsatzTV.Infrastructure/Jellyfin/JellyfinApiClient.cs @@ -39,7 +39,7 @@ public class JellyfinApiClient : IJellyfinApiClient return await service.GetSystemInformation(apiKey, cts.Token) .Map(response => new JellyfinServerInformation(response.ServerName, response.OperatingSystem)); } - catch (OperationCanceledException ex) + catch (Exception ex) when (ex is TaskCanceledException or OperationCanceledException) { _logger.LogError(ex, "Timeout getting jellyfin server name"); return BaseError.New("Jellyfin did not respond in time"); diff --git a/ErsatzTV/Pages/TraktLists.razor b/ErsatzTV/Pages/TraktLists.razor index 1291d0b53..619b7a959 100644 --- a/ErsatzTV/Pages/TraktLists.razor +++ b/ErsatzTV/Pages/TraktLists.razor @@ -137,7 +137,7 @@ PagedTraktListsViewModel data = await _mediator.Send(new GetPagedTraktLists(state.Page, state.PageSize), _cts.Token); return new TableData { TotalItems = data.TotalCount, Items = data.Page }; } - catch (Exception ex) when (ex is TaskCanceledException or OperationCanceledException) + catch (Exception ex) when (ex is TaskCanceledException or OperationCanceledException or AggregateException) { return new TableData {