#[derive(Debug, thiserror::Error)]
pub enum CommandError {
#[error("command creation failed (HTTP {status}): {body}")]
CreationFailed { status: u16, body: String },
#[error("command {command_id} timed out (last state: {last_state})")]
Timeout {
command_id: String,
last_state: String,
},
#[error("command {command_id} failed: [{code}] {message}")]
DeploymentError {
command_id: String,
code: String,
message: String,
},
#[error("command {command_id} expired")]
Expired { command_id: String },
#[error("failed to decode response for command {command_id}: {reason}")]
ResponseDecodingFailed { command_id: String, reason: String },
#[error("storage operation failed: {reason}")]
StorageOperationFailed { reason: String },
#[error("HTTP error: {0}")]
HttpError(#[from] reqwest::Error),
#[error("JSON error: {0}")]
JsonError(#[from] serde_json::Error),
}
impl CommandError {
pub fn is_retryable(&self) -> bool {
matches!(
self,
CommandError::Timeout { .. }
| CommandError::HttpError(_)
| CommandError::StorageOperationFailed { .. }
)
}
}