alien_commands_client/
error.rs1#[derive(Debug, thiserror::Error)]
3pub enum CommandError {
4 #[error("command creation failed (HTTP {status}): {body}")]
6 CreationFailed { status: u16, body: String },
7
8 #[error("command {command_id} timed out (last state: {last_state})")]
10 Timeout {
11 command_id: String,
12 last_state: String,
13 },
14
15 #[error("command {command_id} failed: [{code}] {message}")]
17 DeploymentError {
18 command_id: String,
19 code: String,
20 message: String,
21 },
22
23 #[error("command {command_id} expired")]
25 Expired { command_id: String },
26
27 #[error("failed to decode response for command {command_id}: {reason}")]
29 ResponseDecodingFailed { command_id: String, reason: String },
30
31 #[error("storage operation failed: {reason}")]
33 StorageOperationFailed { reason: String },
34
35 #[error("HTTP error: {0}")]
37 HttpError(#[from] reqwest::Error),
38
39 #[error("JSON error: {0}")]
41 JsonError(#[from] serde_json::Error),
42}
43
44impl CommandError {
45 pub fn is_retryable(&self) -> bool {
47 matches!(
48 self,
49 CommandError::Timeout { .. }
50 | CommandError::HttpError(_)
51 | CommandError::StorageOperationFailed { .. }
52 )
53 }
54}