Skip to content

Commit

Permalink
Merge pull request #12 from maracuda/bis/fix_rethrow
Browse files Browse the repository at this point in the history
Заменил метод PrepForRemoting на ExceptionDispatchInfo.Capture
  • Loading branch information
scklepova authored Aug 5, 2024
2 parents f3c9dea + 1fa0abf commit fc9a37e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions GroboContainer.NUnitExtensions/Impl/ExceptionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Reflection;
using System.Runtime.ExceptionServices;

using JetBrains.Annotations;

Expand All @@ -9,16 +10,13 @@ public static class ExceptionExtensions
{
public static void Rethrow([NotNull] this Exception exception)
{
prepForRemotingMethodInfo.Invoke(exception, new object[0]);
throw exception;
ExceptionDispatchInfo.Capture(exception).Throw();
}

public static void RethrowInnerException([NotNull] this TargetInvocationException exception)
{
exception.InnerException?.Rethrow();
throw exception;
}

private static readonly MethodInfo prepForRemotingMethodInfo = typeof(Exception).GetMethod("PrepForRemoting", BindingFlags.NonPublic | BindingFlags.Instance);
}
}

0 comments on commit fc9a37e

Please sign in to comment.