diff --git a/.editorconfig b/.editorconfig index 78c58c6..b77a3d3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -195,6 +195,9 @@ dotnet_separate_import_directive_groups = false dotnet_style_namespace_match_folder = false dotnet_diagnostic.IDE0130.severity = none +[*.{cs,vb}] +dotnet_diagnostic.CA1305.severity = none + # C# formatting rules # https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#c-formatting-rules [*.{cs,csx,cake}] diff --git a/src/BuildingBlocks/EFCore/EfTxBehavior.cs b/src/BuildingBlocks/EFCore/EfTxBehavior.cs index f7e6eb9..a528f4a 100644 --- a/src/BuildingBlocks/EFCore/EfTxBehavior.cs +++ b/src/BuildingBlocks/EFCore/EfTxBehavior.cs @@ -79,13 +79,11 @@ public class EfTxBehavior : IPipelineBehavior + await _persistMessageDbContext.RetryOnFailure(async () => { - await _dbContextBase.SaveChangesAsync(cancellationToken); + await _persistMessageDbContext.SaveChangesAsync(cancellationToken); }); - await _persistMessageDbContext.SaveChangesAsync(cancellationToken); - scope.Complete(); return response; diff --git a/src/BuildingBlocks/Polly/Extensions.cs b/src/BuildingBlocks/Polly/Extensions.cs index 81fe460..3c048e7 100644 --- a/src/BuildingBlocks/Polly/Extensions.cs +++ b/src/BuildingBlocks/Polly/Extensions.cs @@ -1,6 +1,7 @@ namespace BuildingBlocks.Polly; using global::Polly; +using Serilog; using Exception = System.Exception; public static class Extensions @@ -9,10 +10,10 @@ public static class Extensions { var retryPolicy = Policy .Handle() - .Retry(retryCount, (exception, retryAttempt) => + .Retry(retryCount, (exception, retryAttempt, context) => { - Console.WriteLine($"Retry attempt: {retryAttempt}"); - Console.WriteLine($"Exception: {exception.Message}"); + Log.Information($"Retry attempt: {retryAttempt}"); + Log.Error($"Exception: {exception.Message}"); }); return retryPolicy.Execute(action);