1use alien_error::AlienErrorData;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, AlienErrorData, Serialize, Deserialize, PartialEq, Eq)]
9#[serde(rename_all = "camelCase")]
10pub enum ErrorData {
11 #[error(
13 code = "SIGNING_KEY_INVALID",
14 message = "Invalid signing key: {reason}",
15 retryable = "false",
16 internal = "false",
17 http_status_code = 400
18 )]
19 KeyInvalid {
20 reason: String,
22 },
23
24 #[error(
26 code = "SIGNING_STATEMENT_MALFORMED",
27 message = "Malformed statement: {reason}",
28 retryable = "false",
29 internal = "false",
30 http_status_code = 400
31 )]
32 StatementMalformed {
33 reason: String,
35 },
36
37 #[error(
39 code = "SIGNING_WRONG_KIND",
40 message = "Expected a '{expected}' statement, got '{actual}'",
41 retryable = "false",
42 internal = "false",
43 http_status_code = 403
44 )]
45 WrongKind {
46 expected: String,
48 actual: String,
50 },
51
52 #[error(
54 code = "SIGNING_WRONG_PROJECT",
55 message = "The statement is for project '{actual}', not '{expected}'",
56 retryable = "false",
57 internal = "false",
58 http_status_code = 403
59 )]
60 WrongProject {
61 expected: String,
63 actual: String,
65 },
66
67 #[error(
69 code = "SIGNING_WRONG_INSTALL",
70 message = "The statement is for install '{actual}', not '{expected}'",
71 retryable = "false",
72 internal = "false",
73 http_status_code = 403
74 )]
75 WrongInstall {
76 expected: String,
78 actual: String,
80 },
81
82 #[error(
84 code = "SIGNING_WRONG_CHANNEL",
85 message = "The release is for channel '{actual}', but this install follows '{expected}'",
86 retryable = "false",
87 internal = "false",
88 http_status_code = 403
89 )]
90 WrongChannel {
91 expected: String,
93 actual: String,
95 },
96
97 #[error(
99 code = "SIGNING_SIGNATURE_REFUSED",
100 message = "Signature by '{signer}' refused: {reason}",
101 retryable = "false",
102 internal = "false",
103 http_status_code = 403
104 )]
105 SignatureRefused {
106 signer: String,
108 reason: String,
110 },
111
112 #[error(
114 code = "SIGNING_UNSIGNED",
115 message = "The statement is not signed by a key holding the '{role}' role",
116 retryable = "false",
117 internal = "false",
118 http_status_code = 403
119 )]
120 Unsigned {
121 role: String,
123 },
124
125 #[error(
127 code = "SIGNING_EXPIRED",
128 message = "The statement expired at {not_after}",
129 retryable = "false",
130 internal = "false",
131 http_status_code = 403
132 )]
133 Expired {
134 not_after: String,
136 },
137
138 #[error(
140 code = "SIGNING_DENIED",
141 message = "The statement {digest} is on the signer list's deny-list",
142 retryable = "false",
143 internal = "false",
144 http_status_code = 403
145 )]
146 Denied {
147 digest: String,
149 },
150
151 #[error(
153 code = "SIGNING_SIGNER_LIST_REFUSED",
154 message = "Signer list version {version} refused: {reason}",
155 retryable = "false",
156 internal = "false",
157 http_status_code = 403
158 )]
159 SignerListRefused {
160 version: u64,
162 reason: String,
164 },
165
166 #[error(
169 code = "SIGNING_SIGNER_LIST_MISSING",
170 message = "The statement needs signer list version {needed}, but only version {current} is trusted",
171 retryable = "true",
172 internal = "false",
173 http_status_code = 409
174 )]
175 SignerListMissing {
176 needed: u64,
178 current: u64,
180 },
181
182 #[error(
185 code = "SIGNING_SETTINGS_INVALID",
186 message = "Invalid signing settings: {reason}",
187 retryable = "false",
188 internal = "false",
189 http_status_code = 400
190 )]
191 SettingsInvalid {
192 reason: String,
194 },
195
196 #[error(
199 code = "SIGNING_SETTINGS_UNDECIDED",
200 message = "Can't tell whether this install is protected: {reason}",
201 retryable = "true",
202 internal = "false",
203 http_status_code = 503
204 )]
205 SettingsUndecided {
206 reason: String,
208 },
209
210 #[error(
213 code = "SIGNING_TRUST_ROOT_CHANGED",
214 message = "This install accepted state under {accepted} and now finds {found}; it runs nothing new until an operator resets it",
215 retryable = "false",
216 internal = "false",
217 http_status_code = 409
218 )]
219 TrustRootChanged {
220 accepted: String,
222 found: String,
224 },
225
226 #[error(
229 code = "SIGNING_LEDGER_REFUSED",
230 message = "The install's ledger was refused: {reason}",
231 retryable = "false",
232 internal = "false",
233 http_status_code = 409
234 )]
235 LedgerRefused {
236 reason: String,
238 },
239
240 #[error(
242 code = "SIGNING_WORKLOAD_REFUSED",
243 message = "Workload '{workload}' refused: {reason}",
244 retryable = "false",
245 internal = "false",
246 http_status_code = 403
247 )]
248 WorkloadRefused {
249 workload: String,
251 reason: String,
253 },
254
255 #[error(
257 code = "SIGNING_BODY_REFUSED",
258 message = "The '{kind}' statement was refused: {reason}",
259 retryable = "false",
260 internal = "false",
261 http_status_code = 403
262 )]
263 BodyRefused {
264 kind: String,
266 reason: String,
268 },
269}
270
271pub type Result<T> = alien_error::Result<T, ErrorData>;