Created
October 15, 2012 05:25
-
-
Save fresky/3890932 to your computer and use it in GitHub Desktop.
Check exception is fatal or not
This file contains 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
public static bool IsFatal(this Exception exception) | |
{ | |
while (exception != null) | |
{ | |
if (exception as OutOfMemoryException != null && exception as InsufficientMemoryException == null || exception as ThreadAbortException != null || | |
exception as AccessViolationException != null || exception as SEHException != null || exception as StackOverflowException != null) | |
{ | |
return true; | |
} | |
else | |
{ | |
if (exception as TypeInitializationException == null && exception as TargetInvocationException == null) | |
{ | |
break; | |
} | |
exception = exception.InnerException; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment