diff options
author | Alex <alex@adnab.me> | 2022-05-24 12:48:05 +0200 |
---|---|---|
committer | Alex <alex@adnab.me> | 2022-05-24 12:48:05 +0200 |
commit | b2a2d3859fefd53dab0b87274d5aed1f6bb608a3 (patch) | |
tree | 27ea51873d356ccf79ce1f465fd1993861cb9886 /src/k2v-client/error.rs | |
parent | 382e74c798263d042b1c6ca3788c866a8c69c4f4 (diff) | |
download | garage-b2a2d3859fefd53dab0b87274d5aed1f6bb608a3.tar.gz garage-b2a2d3859fefd53dab0b87274d5aed1f6bb608a3.zip |
K2V client improvements (#307)v0.7.2
- [x] Better distinguish error types
- [x] Parse error messages received from server
- [x] Remove `src/` folder layer, we don't have that for other crates
Co-authored-by: Alex Auvolat <alex@adnab.me>
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/307
Co-authored-by: Alex <alex@adnab.me>
Co-committed-by: Alex <alex@adnab.me>
Diffstat (limited to 'src/k2v-client/error.rs')
-rw-r--r-- | src/k2v-client/error.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/k2v-client/error.rs b/src/k2v-client/error.rs new file mode 100644 index 00000000..37c221f2 --- /dev/null +++ b/src/k2v-client/error.rs @@ -0,0 +1,29 @@ +use std::borrow::Cow; + +use thiserror::Error; + +/// Errors returned by this crate +#[derive(Error, Debug)] +pub enum Error { + #[error("{0}, {1}: {2} (path = {3})")] + Remote( + http::StatusCode, + Cow<'static, str>, + Cow<'static, str>, + Cow<'static, str>, + ), + #[error("received invalid response: {0}")] + InvalidResponse(Cow<'static, str>), + #[error("not found")] + NotFound, + #[error("io error: {0}")] + IoError(#[from] std::io::Error), + #[error("rusoto tls error: {0}")] + RusotoTls(#[from] rusoto_core::request::TlsError), + #[error("rusoto http error: {0}")] + RusotoHttp(#[from] rusoto_core::HttpDispatchError), + #[error("deserialization error: {0}")] + Deserialization(#[from] serde_json::Error), + #[error("{0}")] + Message(Cow<'static, str>), +} |