Class FaultHandler<TDescriptor>
- Namespace
- Cuemon.Diagnostics
- Assembly
- Cuemon.Diagnostics.dll
Provides a generic way to implement a fault resolver that evaluate an exception and provide details about it in a developer friendly way.
public abstract class FaultHandler<TDescriptor> where TDescriptor : ExceptionDescriptor
Type Parameters
TDescriptor
- Inheritance
-
FaultHandler<TDescriptor>
- Derived
Constructors
FaultHandler(Func<Exception, bool>, Func<Exception, TDescriptor>)
Initializes a new instance of the FaultResolver class.
protected FaultHandler(Func<Exception, bool> validator, Func<Exception, TDescriptor> descriptor)
Parameters
validatorFunc<Exception, bool>The function delegate that evaluates an Exception.
descriptorFunc<Exception, TDescriptor>The function delegate that provides details about an Exception.
Exceptions
- ArgumentNullException
validatorcannot be null -or-descriptorcannot be null.
Methods
TryResolveFault(Exception, out TDescriptor)
Attempts to resolve TDescriptor from the underlying function delegates.
public bool TryResolveFault(Exception failure, out TDescriptor descriptor)
Parameters
failureExceptionThe Exception that caused the current failure.
descriptorTDescriptorThe resulting
TDescriptorinstance providing the reason of thefailure, ordefault.
Returns
- bool
trueif an instance ofTDescriptorproviding the reason for thefailureis available,falseotherwise.