This repository was archived by the owner on Feb 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathErrorCode.cs
54 lines (47 loc) · 1.47 KB
/
ErrorCode.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
51
52
53
54
// Automatically generated by xdrgen
// DO NOT EDIT or your changes may be overwritten
namespace Stellar.Generated
{
// === xdr source ============================================================
// enum ErrorCode
// {
// ERR_MISC = 0, // Unspecific error
// ERR_DATA = 1, // Malformed data
// ERR_CONF = 2, // Misconfiguration error
// ERR_AUTH = 3, // Authentication failure
// ERR_LOAD = 4 // System overloaded
// };
// ===========================================================================
public class ErrorCode {
public enum ErrorCodeEnum
{
ERR_MISC = 0,
ERR_DATA = 1,
ERR_CONF = 2,
ERR_AUTH = 3,
ERR_LOAD = 4,
}
public ErrorCodeEnum InnerValue { get; set; } = default(ErrorCodeEnum);
public static ErrorCode Create(ErrorCodeEnum v)
{
return new ErrorCode {
InnerValue = v
};
}
public static ErrorCode Decode(IByteReader stream) {
int value = XdrEncoding.DecodeInt32(stream);
switch (value) {
case 0: return Create(ErrorCodeEnum.ERR_MISC);
case 1: return Create(ErrorCodeEnum.ERR_DATA);
case 2: return Create(ErrorCodeEnum.ERR_CONF);
case 3: return Create(ErrorCodeEnum.ERR_AUTH);
case 4: return Create(ErrorCodeEnum.ERR_LOAD);
default:
throw new System.Exception("Unknown enum value: " + value);
}
}
public static void Encode(IByteWriter stream, ErrorCode value) {
XdrEncoding.EncodeInt32((int)value.InnerValue, stream);
}
}
}