Skip to main content

olai_http/
error.rs

1pub type Result<T, E = Error> = std::result::Result<T, E>;
2
3#[derive(thiserror::Error, Debug)]
4pub enum Error {
5    #[error("Reqwest error: {0}")]
6    ReqwestError(#[from] reqwest::Error),
7
8    #[error("Generic error: {source}")]
9    Generic {
10        /// The wrapped error
11        source: Box<dyn std::error::Error + Send + Sync + 'static>,
12    },
13
14    /// Error when the object is not found at given location
15    #[error("Object not found: {source}")]
16    NotFound {
17        /// The wrapped error
18        source: Box<dyn std::error::Error + Send + Sync + 'static>,
19    },
20
21    /// Error when the object already exists
22    #[error("Object at location already exists: {source}")]
23    AlreadyExists {
24        /// The wrapped error
25        source: Box<dyn std::error::Error + Send + Sync + 'static>,
26    },
27
28    /// Error when the required conditions failed for the operation
29    #[error("Request precondition failure: {source}")]
30    Precondition {
31        /// The wrapped error
32        source: Box<dyn std::error::Error + Send + Sync + 'static>,
33    },
34
35    /// Error when the object at the location isn't modified
36    #[error("Object not modified: {source}")]
37    NotModified {
38        /// The wrapped error
39        source: Box<dyn std::error::Error + Send + Sync + 'static>,
40    },
41
42    /// Error when the used credentials don't have enough permission
43    /// to perform the requested operation
44    #[error("The operation lacked the necessary privileges to complete: {source}")]
45    PermissionDenied {
46        /// The wrapped error
47        source: Box<dyn std::error::Error + Send + Sync + 'static>,
48    },
49
50    /// Error when the used credentials lack valid authentication
51    #[error("The operation lacked valid authentication credentials: {source}")]
52    Unauthenticated {
53        /// The wrapped error
54        source: Box<dyn std::error::Error + Send + Sync + 'static>,
55    },
56
57    /// Error when a configuration key is invalid for the store used
58    #[error("Configuration key: '{}' is not valid.", key)]
59    UnknownConfigurationKey {
60        /// The configuration key used
61        key: String,
62    },
63
64    /// Error constructing an HTTP header value from a string
65    #[error("Invalid HTTP header value: {0}")]
66    InvalidHeader(#[from] reqwest::header::InvalidHeaderValue),
67
68    /// Error when writing a recording to disk
69    #[error("Failed to write recording: {0}")]
70    RecordingIo(#[from] std::io::Error),
71
72    /// Error when the system clock is before the Unix epoch
73    #[error("System clock error: time is before Unix epoch")]
74    ClockError,
75}