Table of Contents

Enum FaultSensitivityDetails

Namespace
Cuemon.Diagnostics
Assembly
Cuemon.Core.dll

Specifies the level of sensitive details to include when serializing an ExceptionDescriptor.

[Flags]
public enum FaultSensitivityDetails

Fields

All = FailureWithStackTraceAndData | Evidence

Specifies that all details should be included when serializing an ExceptionDescriptor. Should not be used in a Production environment.

Data = 4

Specifies that Data of the Failure property is included in the serialized result.

Evidence = 8

Specifies that the Evidence property is included in the serialized result.

Failure = 1

Specifies that the Failure property is included in the serialized result.

FailureWithData = Failure | Data

Specifies that the Failure property and the associated Data is included in the serialized result.

FailureWithStackTrace = Failure | StackTrace

Specifies that the Failure property and the associated StackTrace is included in the serialized result.

FailureWithStackTraceAndData = StackTrace | FailureWithData

Specifies that the Failure property and the associated StackTrace and Data is included in the serialized result.

None = 0

Specifies that all sensitive details are excluded. This is the default and should always be used when in the confines of a Production environment.

StackTrace = 2

Specifies that StackTrace of the Failure property is included in the serialized result.

Examples

The following example demonstrates how to use the enum to control the level of sensitive details included when serializing an .

using System;
using Cuemon.Diagnostics; // for FaultSensitivityDetails, ExceptionDescriptor, FaultResolver

namespace MyApp.Examples;

public class FaultSensitivityDetailsExample
{
    public void Demonstrate()
    {
        // Create an exception descriptor with failure details
        var descriptor = new ExceptionDescriptor(
            new InvalidOperationException("Something went wrong."),
            "ERR_OPERATION_FAILED",
            "The requested operation could not be completed.");

        // FaultSensitivityDetails.None (default) - excludes all sensitive details
        FaultSensitivityDetails details = FaultSensitivityDetails.None;
        Console.WriteLine(details); // None

        // Include the Failure (exception) property
        details = FaultSensitivityDetails.Failure;
        Console.WriteLine(details); // Failure

        // Include both Failure and StackTrace
        details = FaultSensitivityDetails.FailureWithStackTrace;
        Console.WriteLine(details); // Failure, StackTrace

        // Include everything (development environments only)
        details = FaultSensitivityDetails.All;
        Console.WriteLine(details); // Failure, StackTrace, Data, Evidence

        // Combine flags manually
        details = FaultSensitivityDetails.Failure | FaultSensitivityDetails.Data;
        Console.WriteLine(details); // FailureWithData

        // Check if a specific flag is set
        bool hasStackTrace = details.HasFlag(FaultSensitivityDetails.StackTrace);
        Console.WriteLine(hasStackTrace); // False

        bool hasFailure = details.HasFlag(FaultSensitivityDetails.Failure);
        Console.WriteLine(hasFailure); // True

}
}