Categorizes exceptions into fatal and weak ones. Fatal exceptions are always rethrown and weak
ones (most likely simple programming mistakes) can be logged and ignored if no debugger is
attached. See http://vasters.com/clemensv/2012/09/06/Are+You+Catching+Falling+Knives.aspx
View code on GitHub
Inheritance Hierarchy
DeltaEngine.Extensions ExceptionExtensions
Namespace: DeltaEngine.Extensions
Assembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The ExceptionExtensions type exposes the following members.
Methods
Name | Description | |
---|---|---|
IsFatal | ||
IsWeak |
Properties
Name | Description | |
---|---|---|
IsDebugMode |
Remarks
Examples
[Test] public void CheckForFatalException() { Assert.IsFalse(new Exception().IsFatal()); Assert.IsTrue(new Exception("", new InvalidOperationException()).IsFatal()); Assert.IsTrue(new InvalidOperationException().IsFatal()); Assert.IsTrue(new OutOfMemoryException().IsFatal()); Assert.IsTrue(new AccessViolationException().IsFatal()); Assert.IsTrue(new StackOverflowException().IsFatal()); Assert.IsTrue(new TargetInvocationException(null).IsFatal()); Assert.IsFalse(new NullReferenceException(null).IsFatal()); }
[Test] public void CheckForWeakException() { Assert.IsFalse(new Exception().IsWeak()); Assert.IsTrue(new ArgumentNullException().IsWeak()); }
[Test] public void MakeSureFatalExceptionsAreRethrown() { try { TryMakeSureFatalExceptionsAreRethrown(); } // ncrunch: no coverage catch (Exception ex) { Assert.IsTrue(ex.IsFatal()); } }
See Also