<PackageReference Include="Polly.Core" Version="8.5.1" />

ExceptionUtilities

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