Repository navigation
Expand file tree
/
Copy pathKeyLoadException.cs
More file actions
58 lines (49 loc) · 2.53 KB
/
Copy pathKeyLoadException.cs
File metadata and controls
58 lines (49 loc) · 2.53 KB
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
51
52
53
54
55
56
57
58
using ManagedCode.Communication;
namespace KeyLoad;
/// <summary>Represents a safe, caller-visible KeyLoad failure with its domain code and HTTP status.</summary>
[Orleans.GenerateSerializer]
[Orleans.Alias(KeyLoadException.NativeAlias)]
public sealed class KeyLoadException : Exception
{
internal const string NativeAlias = "keyload.error.v1";
private const string DefaultSafeDetail = "A KeyLoad operation failed.";
/// <summary>Initializes a KeyLoad exception with the supplied domain code, safe detail, and HTTP status.</summary>
/// <param name="code">Identifies the domain error.</param>
/// <param name="safeDetail">Provides safe caller-visible detail.</param>
/// <param name="statusCode">Provides the HTTP status associated with the error.</param>
public KeyLoadException(ErrorCode code, string safeDetail, int statusCode)
: this(code, safeDetail, statusCode, null)
{
}
/// <summary>Initializes a validation exception with a standard safe detail.</summary>
public KeyLoadException() : this(ErrorCode.Validation, DefaultSafeDetail, Errors.Status(ErrorCode.Validation), null)
{
}
/// <summary>Initializes a validation exception with the supplied message.</summary>
/// <param name="message">Provides safe caller-visible failure detail.</param>
public KeyLoadException(string message) : this(ErrorCode.Validation, message, Errors.Status(ErrorCode.Validation), null)
{
}
/// <summary>Initializes a validation exception with the supplied message and cause.</summary>
/// <param name="message">Provides safe caller-visible failure detail.</param>
/// <param name="innerException">Provides the exception that caused this failure.</param>
public KeyLoadException(string message, Exception innerException)
: this(ErrorCode.Validation, message, Errors.Status(ErrorCode.Validation), innerException)
{
}
internal KeyLoadException(ErrorCode code, string safeDetail, int statusCode, Exception? innerException)
: base(safeDetail, innerException)
{
Code = code;
StatusCode = statusCode;
}
/// <summary>Gets the domain error code.</summary>
[Orleans.Id(0)]
public ErrorCode Code { get; }
/// <summary>Gets the corresponding HTTP status code.</summary>
[Orleans.Id(1)]
public int StatusCode { get; }
/// <summary>Creates the safe problem detail for this failure.</summary>
/// <returns>The problem detail associated with this exception.</returns>
public Problem ToProblem() => Errors.Problem(Code, Message);
}