-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorkerProtocolFaults.cs
More file actions
35 lines (28 loc) · 1.18 KB
/
Copy pathWorkerProtocolFaults.cs
File metadata and controls
35 lines (28 loc) · 1.18 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
namespace DotPython.Protocol;
public static class WorkerProtocolFaultCodes
{
public const string HandshakeFailed = "DPY8103";
public const string WorkerTerminated = "DPY8104";
public const string HardTimeout = "DPY8105";
public const string StaleHandle = "DPY8106";
public const string LimitExceeded = "DPY8107";
public const string RequestCanceled = "DPY8109";
}
public sealed class WorkerProtocolException : Exception
{
public WorkerProtocolException()
: this(CreateFault("A worker protocol failure occurred.")) { }
public WorkerProtocolException(string message)
: this(CreateFault(message)) { }
public WorkerProtocolException(string message, Exception innerException)
: this(CreateFault(message), innerException) { }
public WorkerProtocolException(WorkerFault fault, Exception? innerException = null)
: base(fault?.Message, innerException)
{
ArgumentNullException.ThrowIfNull(fault);
Fault = fault;
}
public WorkerFault Fault { get; }
private static WorkerFault CreateFault(string message) =>
new(WorkerProtocolFaultCodes.HandshakeFailed, WorkerFaultPhase.Framing, message, false);
}