garage_sdk/error/
types.rs

1use thiserror::Error;
2
3/// All possible errors that can occur when using the Garage SDK.
4#[derive(Error, Debug)]
5pub enum Error {
6    /// Configuration is invalid or incomplete.
7    #[error("Configuration error: {message}")]
8    Config { message: String },
9
10    /// Failed to parse or validate a URL.
11    #[error("Invalid URL '{url}': {reason}")]
12    InvalidUrl { url: String, reason: String },
13
14    /// Failed to read a local file.
15    #[error("Failed to read file '{path}': {source}")]
16    FileRead {
17        path: String,
18        #[source]
19        source: std::io::Error,
20    },
21
22    /// Failed to download content from a URL.
23    #[error("Failed to download from '{url}': {reason}")]
24    Download { url: String, reason: String },
25
26    /// HTTP request failed.
27    #[error("HTTP error: {0}")]
28    Http(#[from] reqwest::Error),
29
30    /// S3 operation failed.
31    #[error("S3 operation failed: {operation} - {reason}")]
32    S3Operation { operation: String, reason: String },
33
34    /// Content type could not be determined.
35    #[error("Could not determine content type for '{filename}'")]
36    UnknownContentType { filename: String },
37
38    /// Invalid file path provided.
39    #[error("Invalid file path: {reason}")]
40    InvalidPath { reason: String },
41}
42
43/// Result type alias for Garage SDK operations.
44pub type Result<T> = std::result::Result<T, Error>;