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