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 | EvidenceSpecifies that all details should be included when serializing an ExceptionDescriptor. Should not be used in a Production environment.
Data = 4Specifies that Data of the Failure property is included in the serialized result.
Evidence = 8Specifies that the Evidence property is included in the serialized result.
Failure = 1Specifies that the Failure property is included in the serialized result.
FailureWithData = Failure | DataSpecifies that the Failure property and the associated Data is included in the serialized result.
FailureWithStackTrace = Failure | StackTraceSpecifies that the Failure property and the associated StackTrace is included in the serialized result.
FailureWithStackTraceAndData = StackTrace | FailureWithDataSpecifies that the Failure property and the associated StackTrace and Data is included in the serialized result.
None = 0Specifies that all sensitive details are excluded. This is the default and should always be used when in the confines of a Production environment.
StackTrace = 2Specifies that StackTrace of the Failure property is included in the serialized result.
Examples
The following example demonstrates how to use the
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
}
}