Created
June 29, 2017 13:34
-
-
Save alastairtree/b323b033ba108a6caa5e92e9c3def51d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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