Table of Contents

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 Exception

The Exception that caused the current failure.

code String

The error code that uniquely identifies the type of failure.

message String

The message that explains the reason for the failure.

helpLink Uri

The 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.

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 String

The context of the evidence.

evidence T

The 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 Exception

The Exception to convert.

code String

The error code that uniquely identifies the type of failure. Default is "UnhandledException".

message String

The message that explains the reason for the failure. Default is "An unhandled exception occurred.".

helpLink Uri

The 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()

Returns

String

A String that represents this instance.