<PackageReference Include="Polly.Core" Version="8.0.0-alpha.8" />

ExceptionUtilities

static class ExceptionUtilities
using System; using System.Runtime.CompilerServices; using System.Runtime.ExceptionServices; namespace Polly.Utils { internal static class ExceptionUtilities { [System.Runtime.CompilerServices.NullableContext(1)] public static T TrySetStackTrace<[System.Runtime.CompilerServices.Nullable(0)] T>(this T exception) where T : Exception { if (!string.IsNullOrWhiteSpace(exception.StackTrace)) return exception; ExceptionDispatchInfo.SetCurrentStackTrace(exception); return exception; } } }