improve logging fallback

This commit is contained in:
azyges
2025-10-22 03:33:51 +09:00
parent 1a89c2caee
commit 6bb00c50d8

View File

@@ -215,6 +215,26 @@ public partial class FileDownloadManager : DisposableMediatorSubscriberBase
await Task.Delay(retryDelay, ct).ConfigureAwait(false);
}
catch (TaskCanceledException ex) when (!ct.IsCancellationRequested)
{
response?.Dispose();
retryCount++;
Logger.LogWarning(ex, "Cancellation/timeout during download of {requestUrl}. Attempt {attempt} of {maxRetries}", requestUrl, retryCount, maxRetries);
if (retryCount >= maxRetries)
{
Logger.LogError("Max retries reached for {requestUrl} after TaskCanceledException", requestUrl);
throw;
}
await Task.Delay(retryDelay, ct).ConfigureAwait(false);
}
catch (OperationCanceledException) when (ct.IsCancellationRequested)
{
response?.Dispose();
throw;
}
catch (HttpRequestException ex)
{
response?.Dispose();