Skip to content

Commit

Permalink
Warning upon retry
Browse files Browse the repository at this point in the history
  • Loading branch information
lemaitre-aneo committed Jun 20, 2024
1 parent 9a94e51 commit bb418da
Showing 1 changed file with 32 additions and 16 deletions.
48 changes: 32 additions & 16 deletions Common/src/Common/RetryAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ public static void WhileException(int retries,
if (exceptionType != null && allowDerivedExceptions && ex is AggregateException &&
exceptionType.Any(e => ex.InnerException != null && ex.InnerException.GetType() == e))
{
logger?.LogDebug("Got exception while executing function to retry : {ex}",
ex);
logger?.LogWarning(ex,
"Got exception while executing function to retry {retry}/{retries}",
retry,
retries);
Thread.Sleep(delayMs);
}
else if (exceptionType == null || exceptionType.Any(e => e == ex.GetType()) || (allowDerivedExceptions && exceptionType.Any(e => ex.GetType()
Expand All @@ -123,8 +125,10 @@ public static void WhileException(int retries,
// Ignore exceptions when exceptionType is not specified OR
// the exception thrown was of the specified exception type OR
// the exception thrown is derived from the specified exception type and we allow that
logger?.LogDebug("Got exception while executing function to retry : {ex}",
ex);
logger?.LogWarning(ex,
"Got exception while executing function to retry {retry}/{retries}",
retry,
retries);
Thread.Sleep(delayMs);
}
else
Expand Down Expand Up @@ -197,8 +201,10 @@ public static T WhileException<T>(int retries,
if (exceptionType != null && allowDerivedExceptions && ex is AggregateException &&
exceptionType.Any(e => ex.InnerException != null && ex.InnerException.GetType() == e))
{
logger?.LogDebug("Got exception while executing function to retry : {ex}",
ex);
logger?.LogWarning(ex,
"Got exception while executing function to retry {retry}/{retries}",
retry,
retries);
Thread.Sleep(delayMs);
}
else if (exceptionType == null || exceptionType.Any(e => e == ex.GetType()) || (allowDerivedExceptions && exceptionType.Any(e => ex.GetType()
Expand All @@ -207,8 +213,10 @@ public static T WhileException<T>(int retries,
// Ignore exceptions when exceptionType is not specified OR
// the exception thrown was of the specified exception type OR
// the exception thrown is derived from the specified exception type and we allow that
logger?.LogDebug("Got exception while executing function to retry : {ex}",
ex);
logger?.LogWarning(ex,
"Got exception while executing function to retry {retry}/{retries}",
retry,
retries);
Thread.Sleep(delayMs);
}
else
Expand Down Expand Up @@ -293,8 +301,10 @@ await operation(retry)
if (exceptionType != null && allowDerivedExceptions && ex is AggregateException &&
exceptionType.Any(e => ex.InnerException != null && ex.InnerException.GetType() == e))
{
logger?.LogDebug("Got exception while executing function to retry : {ex}",
ex);
logger?.LogWarning(ex,
"Got exception while executing function to retry {retry}/{retries}",
retry,
retries);
Thread.Sleep(delayMs);
}
else if (exceptionType == null || exceptionType.Any(e => e == ex.GetType()) || (allowDerivedExceptions && exceptionType.Any(e => ex.GetType()
Expand All @@ -303,8 +313,10 @@ await operation(retry)
// Ignore exceptions when exceptionType is not specified OR
// the exception thrown was of the specified exception type OR
// the exception thrown is derived from the specified exception type and we allow that
logger?.LogDebug("Got exception while executing function to retry : {ex}",
ex);
logger?.LogWarning(ex,
"Got exception while executing function to retry {retry}/{retries}",
retry,
retries);
await Task.Delay(delayMs,
cancellationToken)
.ConfigureAwait(false);
Expand Down Expand Up @@ -385,8 +397,10 @@ public static async ValueTask<T> WhileException<T>(int retri
if (exceptionType != null && allowDerivedExceptions && ex is AggregateException &&
exceptionType.Any(e => ex.InnerException != null && ex.InnerException.GetType() == e))
{
logger?.LogDebug("Got exception while executing function to retry : {ex}",
ex);
logger?.LogWarning(ex,
"Got exception while executing function to retry {retry}/{retries}",
retry,
retries);
await Task.Delay(delayMs,
cancellationToken)
.ConfigureAwait(false);
Expand All @@ -397,8 +411,10 @@ await Task.Delay(delayMs,
// Ignore exceptions when exceptionType is not specified OR
// the exception thrown was of the specified exception type OR
// the exception thrown is derived from the specified exception type and we allow that
logger?.LogDebug("Got exception while executing function to retry : {ex}",
ex);
logger?.LogWarning(ex,
"Got exception while executing function to retry {retry}/{retries}",
retry,
retries);
await Task.Delay(delayMs,
cancellationToken)
.ConfigureAwait(false);
Expand Down

0 comments on commit bb418da

Please sign in to comment.