File tree Expand file tree Collapse file tree
StabilityMatrix.Core/Models Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using System . Diagnostics . CodeAnalysis ;
2+ using System . Security . Authentication ;
23using System . Text . Json . Serialization ;
34using AsyncAwaitBestPractices ;
45using NLog ;
@@ -316,6 +317,15 @@ private void DoCleanup()
316317 }
317318 }
318319
320+ /// <summary>
321+ /// Returns true for transient network/SSL exceptions that are safe to retry.
322+ /// </summary>
323+ private static bool IsTransientNetworkException ( Exception ? ex ) =>
324+ ex is IOException or AuthenticationException
325+ || ex ? . InnerException is IOException or AuthenticationException
326+ || ex is AggregateException ae
327+ && ae . InnerExceptions . Any ( e => e is IOException or AuthenticationException ) ;
328+
319329 /// <summary>
320330 /// Invoked by the task's completion callback
321331 /// </summary>
@@ -349,7 +359,7 @@ private void OnDownloadTaskCompleted(Task task)
349359 // Set the exception
350360 Exception = task . Exception ;
351361
352- if ( ( Exception is IOException || Exception ? . InnerException is IOException ) && attempts < 3 )
362+ if ( IsTransientNetworkException ( Exception ) && attempts < 3 )
353363 {
354364 attempts ++ ;
355365 Logger . Warn (
You can’t perform that action at this time.
0 commit comments