Class ExceptionDescriptor
- Namespace
- Cuemon.Diagnostics
- Assembly
- Cuemon.Core.dll
Provides information about an Exception, in a developer friendly way.
public class ExceptionDescriptor
- Inheritance
-
ExceptionDescriptor
Constructors
ExceptionDescriptor()
Initializes a new instance of the ExceptionDescriptor class.
protected ExceptionDescriptor()
ExceptionDescriptor(Exception, String, String, Uri)
Initializes a new instance of the ExceptionDescriptor class.
public ExceptionDescriptor(Exception failure, string code, string message, Uri helpLink = null)
Parameters
failure
ExceptionThe Exception that caused the current failure.
code
StringThe error code that uniquely identifies the type of failure.
message
StringThe message that explains the reason for the failure.
helpLink
UriThe optional link to a help page associated with this failure.
Remarks
code
will remove any spaces that might be present.
Properties
Code
Gets an error code that uniquely identifies the type of failure.
public string Code { get; }
Property Value
- String
The number that identifies the type of failure.
Evidence
Gets a collection of key/value pairs that can provide additional information about the failure.
public IReadOnlyDictionary<string, object> Evidence { get; }
Property Value
- IReadOnlyDictionary<String, Object>
An optional collection of key/value pairs that can provide additional information about the failure.
Failure
Gets the Exception that caused the current failure.
public Exception Failure { get; }
Property Value
- Exception
The deeper cause of the failure.
HelpLink
Gets or sets a link to the help page associated with this failure.
public Uri HelpLink { get; set; }
Property Value
- Uri
The location of an optional help page associated with this failure.
Message
Gets a message that describes the current failure.
public string Message { get; }
Property Value
- String
The message that explains the reason for the failure.
Methods
AddEvidence<T>(String, T, Func<T, Object>)
Adds an element of evidence to associate with the faulted operation.
public void AddEvidence<T>(string context, T evidence, Func<T, object> evidenceProvider)
Parameters
context
StringThe context of the evidence.
evidence
TThe evidence itself.
evidenceProvider
Func<T, Object>The function delegate that provides the evidence.
Type Parameters
T
The type of the
evidence
.
Extract(Exception, String, String, Uri)
Converts the specified exception
to a developer friendly ExceptionDescriptor.
public static ExceptionDescriptor Extract(Exception exception, string code = "UnhandledException", string message = "An unhandled exception occurred.", Uri helpLink = null)
Parameters
exception
ExceptionThe Exception to convert.
code
StringThe error code that uniquely identifies the type of failure. Default is "UnhandledException".
message
StringThe message that explains the reason for the failure. Default is "An unhandled exception occurred.".
helpLink
UriThe optional link to a help page associated with this failure.
Returns
- ExceptionDescriptor
An ExceptionDescriptor initialized with the provided arguments, and (if embedded) enriched with insights of the
exception
.
Remarks
Any meta data embedded by Embed<T>(T, Object[], SystemSnapshots) will be extracted and added as evidence to the final result.
PostInitializeWith(ExceptionDescriptorAttribute)
Post initialize this instance with the specified attribute
.
public void PostInitializeWith(ExceptionDescriptorAttribute attribute)
Parameters
attribute
ExceptionDescriptorAttribute
PostInitializeWith(IEnumerable<ExceptionDescriptorAttribute>)
Post initialize this instance with a matching ExceptionDescriptorAttribute from the specified attributes
.
public void PostInitializeWith(IEnumerable<ExceptionDescriptorAttribute> attributes)
Parameters
attributes
IEnumerable<ExceptionDescriptorAttribute>The attributes to find a match within.
ToString()
Returns a String that represents this instance.
public override string ToString()