firecracker_http_client/
error.rs1use std::path::PathBuf;
2use thiserror::Error;
3use url::ParseError;
4use validator::ValidationErrors;
5
6#[derive(Error, Debug)]
8pub enum FirecrackerError {
9 #[error("HTTP client error: {0}")]
11 HttpClient(#[from] reqwest::Error),
12
13 #[error("URL parse error: {0}")]
15 UrlParseError(#[from] ParseError),
16
17 #[error("Serialization error: {0}")]
19 Serialization(#[from] serde_json::Error),
20
21 #[error("Validation error: {0}")]
23 Validation(#[from] ValidationErrors),
24
25 #[error("Firecracker API error: {status_code} - {message}")]
27 Api { status_code: u16, message: String },
28
29 #[error("Invalid path: {0}")]
31 InvalidPath(String),
32
33 #[error("File system error for path {path}: {source}")]
35 FileSystem {
36 path: PathBuf,
37 source: std::io::Error,
38 },
39
40 #[error("Configuration error: {0}")]
42 Config(String),
43
44 #[error("Snapshot error: {0}")]
46 Snapshot(String),
47
48 #[error("Rate limit exceeded: {0}")]
50 RateLimit(String),
51
52 #[error("Invalid VM state: {current_state}. Expected one of: {expected_states:?}")]
54 InvalidState {
55 current_state: String,
56 expected_states: Vec<String>,
57 },
58
59 #[error("Operation timed out after {duration_secs} seconds")]
61 Timeout { duration_secs: u64 },
62
63 #[error("Internal error: {0}")]
65 Internal(String),
66}
67
68pub type FirecrackerResult<T> = Result<T, FirecrackerError>;