-
Notifications
You must be signed in to change notification settings - Fork 764
/
Copy pathFailureResultContext.cs
50 lines (43 loc) · 2.02 KB
/
FailureResultContext.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.Extensions.Http.Diagnostics;
using Microsoft.Shared.Diagnostics;
namespace Microsoft.Extensions.Resilience;
/// <summary>
/// Captures the dimensions metered for a transient failure result.
/// </summary>
#pragma warning disable CA1815 // Override equals and operator equals on value types (Such usage is not expected in this scenario)
public readonly struct FailureResultContext
#pragma warning restore CA1815
{
/// <summary>
/// Initializes a new instance of the <see cref="FailureResultContext" /> structure.
/// </summary>
/// <param name="failureSource">The source of the failure.</param>
/// <param name="failureReason">The reason of the failure.</param>
/// <param name="additionalInformation">Additional information for the failure.</param>
/// <returns>To be added.</returns>
public static FailureResultContext Create(
string failureSource = TelemetryConstants.Unknown,
string failureReason = TelemetryConstants.Unknown,
string additionalInformation = TelemetryConstants.Unknown)
=> new(failureSource, failureReason, additionalInformation);
private FailureResultContext(string failureSource, string failureReason, string additionalInformation)
{
FailureSource = Throw.IfNullOrEmpty(failureSource);
FailureReason = Throw.IfNullOrEmpty(failureReason);
AdditionalInformation = Throw.IfNullOrEmpty(additionalInformation);
}
/// <summary>
/// Gets the source of the failure presented in the delegate result.
/// </summary>
public string FailureSource { get; }
/// <summary>
/// Gets the reason of the failure presented in the delegate result.
/// </summary>
public string FailureReason { get; }
/// <summary>
/// Gets additional information of the failure presented in the delegate result.
/// </summary>
public string AdditionalInformation { get; }
}