Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@alastairtree
Created June 29, 2017 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alastairtree/b323b033ba108a6caa5e92e9c3def51d to your computer and use it in GitHub Desktop.
Save alastairtree/b323b033ba108a6caa5e92e9c3def51d to your computer and use it in GitHub Desktop.
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