objectstore_client/error.rs
1use std::sync::Arc;
2
3/// Errors that can happen within the objectstore-client
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6 /// Any error emitted from the underlying [`reqwest`] client.
7 #[error(transparent)]
8 Reqwest(#[from] reqwest::Error),
9 /// IO errors related to payload streaming.
10 #[error(transparent)]
11 Io(#[from] std::io::Error),
12 /// Errors related to UTF-8 dcoding
13 #[error(transparent)]
14 Utf8(#[from] std::string::FromUtf8Error),
15 /// Errors handling metadata, such as serializing it to/from HTTP headers.
16 #[error(transparent)]
17 Metadata(#[from] objectstore_types::metadata::Error),
18 /// Error when scope validation fails.
19 #[error("invalid scope: {0}")]
20 InvalidScope(#[from] objectstore_types::scope::InvalidScopeError),
21 /// Error when creating auth tokens, such as invalid keys.
22 #[error(transparent)]
23 TokenError(#[from] jsonwebtoken::errors::Error),
24 /// Error when URL manipulation fails.
25 #[error("{message}")]
26 InvalidUrl {
27 /// The URL error message.
28 message: String,
29 },
30 /// Error when parsing a multipart response.
31 #[error(transparent)]
32 Multipart(#[from] multer::Error),
33 /// Error when the server returned a malformed response.
34 #[error("{0}")]
35 MalformedResponse(String),
36 /// Error that indicates that an entire batch request failed.
37 #[error("batch request failed: {0}")]
38 Batch(Arc<Error>),
39 /// Error that indicates failure of an individual operation in a batch request.
40 #[error("operation failed with HTTP status code {status}: {message}")]
41 OperationFailure {
42 /// The HTTP status code corresponding to the status of the operation.
43 status: u16,
44 /// The error message.
45 message: String,
46 },
47}
48
49/// A convenience alias that defaults our [`Error`] type.
50pub type Result<T, E = Error> = std::result::Result<T, E>;