Skip to content

Instantly share code, notes, and snippets.

@fresky
Created October 15, 2012 05:25
Show Gist options
  • Save fresky/3890932 to your computer and use it in GitHub Desktop.
Save fresky/3890932 to your computer and use it in GitHub Desktop.
Check exception is fatal or not
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