Table of Contents

Failure Class

Definition

Namespace
Cuemon.Diagnostics
Assemblies
Cuemon.Core.dll
Source
src/Cuemon.Core/Diagnostics/Failure.cs

Represents a failure model with detailed information about an exception.

public record Failure : IReadOnlyDictionary<string, object>, IReadOnlyCollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, IEnumerable, IEquatable<Failure>
Inheritance
Failure
Implements

Examples

The following example demonstrates how to use the record to expose structured exception details for diagnostics.

using System;
using Cuemon.Diagnostics;

namespace MyApp.Examples;

public static class FailureExample
{
    public static void Demonstrate()
    {
        var exception = new InvalidOperationException("The operation could not be completed.");
        exception.Data["OperationId"] = "OP-42";

        var failure = new Failure(exception, FaultSensitivityDetails.StackTrace | FaultSensitivityDetails.Data);

        Console.WriteLine(failure.Type);
        Console.WriteLine(failure.Message);
        Console.WriteLine(failure.Data["OperationId"]);
        Console.WriteLine(failure.GetUnderlyingSensitivity());
    }
}

Constructors

Name Description
Failure(Exception, FaultSensitivityDetails)

Initializes a new instance of the Failure class.

Properties

Name Description
Data

Gets the data associated with the underlying exception.

Message

Gets the message of the underlying exception.

Namespace

Gets the namespace of the underlying exception.

Source

Gets the source of the underlying exception.

Stack

Gets the stack trace of the underlying exception.

Type

Gets the type of the underlying exception.

Methods

Name Description
GetUnderlyingException()

Gets the underlying exception to this Failure.

GetUnderlyingSensitivity()

Gets the underlying sensitivity details of this Failure.