Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
namespace Util
{
public static class ExceptionExtensions
{
public static T Unwrap<T>(this Exception exception) where T : class
{
return exception.InnerException?.Unwrap<T>() ?? exception as T;
}
public static Exception Unwrap(this Exception exception)
{
return exception.InnerException?.Unwrap() ?? exception;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment