You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel/Services/Async/ExceptionHelpers.cs

23 lines
821 B

using System;
using System.Runtime.ExceptionServices;
namespace ZeroLevel.Services.Async
{
/// <summary>
/// Provides helper (non-extension) methods dealing with exceptions.
/// </summary>
public static class ExceptionHelpers
{
/// <summary>
/// Attempts to prepare the exception for re-throwing by preserving the stack trace.
/// The returned exception should be immediately thrown.
/// </summary>
/// <param name="exception">The exception. May not be <c>null</c>.</param>
/// <returns>The <see cref="Exception"/> that was passed into this method.</returns>
public static Exception PrepareForRethrow(Exception exception)
{
ExceptionDispatchInfo.Capture(exception).Throw();
return exception;
}
}
}

Powered by TurnKey Linux.