ExceptionExtensions
Contains extension methods on the  Exception class.
            
                using System;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
namespace Polly.Utilities
{
    public static class ExceptionExtensions
    {
        [System.Runtime.CompilerServices.NullableContext(1)]
        public static void RethrowWithOriginalStackTraceIfDiffersFrom(this Exception exceptionPossiblyToThrow, Exception exceptionToCompare)
        {
            if (exceptionPossiblyToThrow != exceptionToCompare)
                ExceptionDispatchInfo.Capture(exceptionPossiblyToThrow).Throw();
        }
    }
}