immich_lib/error.rs
1//! Error types for the Immich API client.
2
3use thiserror::Error;
4
5/// Errors that can occur when interacting with the Immich API.
6#[derive(Error, Debug)]
7pub enum ImmichError {
8 /// HTTP request failed (network error, timeout, etc.)
9 #[error("HTTP request failed: {0}")]
10 Http(#[from] reqwest::Error),
11
12 /// API returned an error response
13 #[error("API error {status}: {message}")]
14 Api {
15 /// HTTP status code
16 status: u16,
17 /// Error message from the API
18 message: String,
19 },
20
21 /// Invalid URL format
22 #[error("Invalid URL: {0}")]
23 Url(#[from] url::ParseError),
24
25 /// API key is malformed or invalid
26 #[error("Invalid API key format")]
27 InvalidApiKey,
28
29 /// Requested asset was not found
30 #[error("Asset not found: {0}")]
31 AssetNotFound(String),
32
33 /// File I/O error
34 #[error("I/O error: {0}")]
35 Io(#[from] std::io::Error),
36}
37
38/// Convenience type alias for Results using ImmichError.
39pub type Result<T> = std::result::Result<T, ImmichError>;