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, Boolean>, Func<Exception, TDescriptor>)
Initializes a new instance of the FaultResolver class.
protected FaultHandler(Func<Exception, bool> validator, Func<Exception, TDescriptor> descriptor)
Parameters
validator
Func<Exception, Boolean>The function delegate that evaluates an Exception.
descriptor
Func<Exception, TDescriptor>The function delegate that provides details about an Exception.
Exceptions
- ArgumentNullException
validator
cannot be null -or-descriptor
cannot 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
failure
ExceptionThe Exception that caused the current failure.
descriptor
TDescriptorThe resulting
TDescriptor
instance providing the reason of thefailure
, ordefault
.
Returns
- Boolean
true
if an instance ofTDescriptor
providing the reason for thefailure
is available,false
otherwise.