1#[derive(Debug, Eq, PartialEq, Hash, Copy, Clone, serde::Deserialize, serde::Serialize)]
3pub struct ErrorCode(i32);
4
5impl ErrorCode {
6 pub const OK: Self = ErrorCode(0);
8
9 pub const EINTERNAL: Self = ErrorCode(-1);
11
12 pub const EARGS: Self = ErrorCode(-2);
14
15 pub const EAGAIN: Self = ErrorCode(-3);
17
18 pub const ERATELIMIT: Self = ErrorCode(-4);
20
21 pub const EFAILED: Self = ErrorCode(-5);
23
24 pub const ETOOMANY: Self = ErrorCode(-6);
26
27 pub const ERANGE: Self = ErrorCode(-7);
29
30 pub const EEXPIRED: Self = ErrorCode(-8);
32
33 pub const ENOENT: Self = ErrorCode(-9);
35
36 pub const ECIRCULAR: Self = ErrorCode(-10);
38
39 pub const EACCESS: Self = ErrorCode(-11);
41
42 pub const EEXIST: Self = ErrorCode(-12);
44
45 pub const EINCOMPLETE: Self = ErrorCode(-13);
47
48 pub const EKEY: Self = ErrorCode(-14);
50
51 pub const ESID: Self = ErrorCode(-15);
53
54 pub const EBLOCKED: Self = ErrorCode(-16);
56
57 pub const EOVERQUOTA: Self = ErrorCode(-17);
59
60 pub const ETEMPUNAVAIL: Self = ErrorCode(-18);
62
63 pub const ETOOMANYCONNECTIONS: Self = ErrorCode(-19);
65
66 pub const EWRITE: Self = ErrorCode(-20);
68
69 pub const EREAD: Self = ErrorCode(-21);
71
72 pub const EAPPKEY: Self = ErrorCode(-22);
74
75 pub const ESSL: Self = ErrorCode(-23);
77
78 pub const EGOINGOVERQUOTA: Self = ErrorCode(-24);
80
81 pub const EMFAREQUIRED: Self = ErrorCode(-26);
83
84 pub const EMASTERONLY: Self = ErrorCode(-27);
86
87 pub const EBUSINESSPASTDUE: Self = ErrorCode(-28);
89
90 pub const EPAYWALL: Self = ErrorCode(-29);
92
93 pub fn description(self) -> &'static str {
95 match self {
96 Self::OK => "No error",
97 Self::EINTERNAL => "Internal error",
98 Self::EARGS => "Invalid argument",
99 Self::EAGAIN => "Request failed, retrying",
100 Self::ERATELIMIT => "Rate limit exceeded",
101 Self::EFAILED => "Failed permanently",
102 Self::ETOOMANY => "Too many concurrent connections or transfers", Self::ERANGE => "Out of range",
104 Self::EEXPIRED => "Expired",
105 Self::ENOENT => "Not found",
106 Self::ECIRCULAR => "Circular linkage detected", Self::EACCESS => "Access denied",
108 Self::EEXIST => "Already exists",
109 Self::EINCOMPLETE => "Incomplete",
110 Self::EKEY => "Invalid key/Decryption error",
111 Self::ESID => "Bad session ID",
112 Self::EBLOCKED => "Blocked", Self::EOVERQUOTA => "Over quota",
114 Self::ETEMPUNAVAIL => "Temporarily not available",
115 Self::ETOOMANYCONNECTIONS => "Connection overflow",
116 Self::EWRITE => "Write error",
117 Self::EREAD => "Read error",
118 Self::EAPPKEY => "Invalid application key",
119 Self::ESSL => "SSL verification failed",
120 Self::EGOINGOVERQUOTA => "Not enough quota",
121 Self::EMFAREQUIRED => "Multi-factor authentication required",
122 Self::EMASTERONLY => "Access denied for users",
123 Self::EBUSINESSPASTDUE => "Business account has expired",
124 Self::EPAYWALL => "Storage Quota Exceeded. Upgrade now",
125 _ => "Unknown error",
126 }
127 }
128}
129
130impl std::fmt::Display for ErrorCode {
131 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
132 write!(f, "{}", self.description())
133 }
134}
135
136impl std::error::Error for ErrorCode {}