mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-31 01:09:24 +00:00
migrate to this error
it doesn't generate a bazillion warning at compile time
This commit is contained in:
Generated
+13
-45
@@ -1113,20 +1113,6 @@ version = "1.0.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "err-derive"
|
|
||||||
version = "0.3.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c34a887c8df3ed90498c1c437ce21f211c8e27672921a8ffa293cb8d6d4caa9e"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro-error",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"rustversion",
|
|
||||||
"syn 1.0.109",
|
|
||||||
"synstructure 0.12.6",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "errno"
|
name = "errno"
|
||||||
version = "0.3.10"
|
version = "0.3.10"
|
||||||
@@ -1356,7 +1342,6 @@ dependencies = [
|
|||||||
"async-trait",
|
"async-trait",
|
||||||
"bytesize",
|
"bytesize",
|
||||||
"chrono",
|
"chrono",
|
||||||
"err-derive",
|
|
||||||
"format_table",
|
"format_table",
|
||||||
"futures",
|
"futures",
|
||||||
"garage_api_common",
|
"garage_api_common",
|
||||||
@@ -1374,6 +1359,7 @@ dependencies = [
|
|||||||
"prometheus",
|
"prometheus",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"thiserror 2.0.12",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"url",
|
"url",
|
||||||
@@ -1389,7 +1375,6 @@ dependencies = [
|
|||||||
"chrono",
|
"chrono",
|
||||||
"crc-fast",
|
"crc-fast",
|
||||||
"crypto-common",
|
"crypto-common",
|
||||||
"err-derive",
|
|
||||||
"futures",
|
"futures",
|
||||||
"garage_model",
|
"garage_model",
|
||||||
"garage_table",
|
"garage_table",
|
||||||
@@ -1408,6 +1393,7 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"sha1",
|
"sha1",
|
||||||
"sha2",
|
"sha2",
|
||||||
|
"thiserror 2.0.12",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"url",
|
"url",
|
||||||
@@ -1418,7 +1404,6 @@ name = "garage_api_k2v"
|
|||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.21.7",
|
"base64 0.21.7",
|
||||||
"err-derive",
|
|
||||||
"futures",
|
"futures",
|
||||||
"garage_api_common",
|
"garage_api_common",
|
||||||
"garage_model",
|
"garage_model",
|
||||||
@@ -1431,6 +1416,7 @@ dependencies = [
|
|||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"thiserror 2.0.12",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"url",
|
"url",
|
||||||
@@ -1446,7 +1432,6 @@ dependencies = [
|
|||||||
"bytes",
|
"bytes",
|
||||||
"chrono",
|
"chrono",
|
||||||
"crc-fast",
|
"crc-fast",
|
||||||
"err-derive",
|
|
||||||
"form_urlencoded",
|
"form_urlencoded",
|
||||||
"futures",
|
"futures",
|
||||||
"garage_api_common",
|
"garage_api_common",
|
||||||
@@ -1474,6 +1459,7 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"sha1",
|
"sha1",
|
||||||
"sha2",
|
"sha2",
|
||||||
|
"thiserror 2.0.12",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-stream",
|
"tokio-stream",
|
||||||
"tokio-util 0.7.14",
|
"tokio-util 0.7.14",
|
||||||
@@ -1509,7 +1495,6 @@ dependencies = [
|
|||||||
name = "garage_db"
|
name = "garage_db"
|
||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"err-derive",
|
|
||||||
"fjall",
|
"fjall",
|
||||||
"heed",
|
"heed",
|
||||||
"mktemp",
|
"mktemp",
|
||||||
@@ -1517,6 +1502,7 @@ dependencies = [
|
|||||||
"r2d2",
|
"r2d2",
|
||||||
"r2d2_sqlite",
|
"r2d2_sqlite",
|
||||||
"rusqlite",
|
"rusqlite",
|
||||||
|
"thiserror 2.0.12",
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1529,7 +1515,6 @@ dependencies = [
|
|||||||
"base64 0.21.7",
|
"base64 0.21.7",
|
||||||
"blake2",
|
"blake2",
|
||||||
"chrono",
|
"chrono",
|
||||||
"err-derive",
|
|
||||||
"futures",
|
"futures",
|
||||||
"garage_block",
|
"garage_block",
|
||||||
"garage_db",
|
"garage_db",
|
||||||
@@ -1543,6 +1528,7 @@ dependencies = [
|
|||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_bytes",
|
"serde_bytes",
|
||||||
|
"thiserror 2.0.12",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"zstd",
|
"zstd",
|
||||||
@@ -1555,7 +1541,6 @@ dependencies = [
|
|||||||
"arc-swap",
|
"arc-swap",
|
||||||
"bytes",
|
"bytes",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"err-derive",
|
|
||||||
"futures",
|
"futures",
|
||||||
"hex",
|
"hex",
|
||||||
"kuska-handshake",
|
"kuska-handshake",
|
||||||
@@ -1568,6 +1553,7 @@ dependencies = [
|
|||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"rmp-serde",
|
"rmp-serde",
|
||||||
"serde",
|
"serde",
|
||||||
|
"thiserror 2.0.12",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-stream",
|
"tokio-stream",
|
||||||
"tokio-util 0.7.14",
|
"tokio-util 0.7.14",
|
||||||
@@ -1580,7 +1566,6 @@ dependencies = [
|
|||||||
"arc-swap",
|
"arc-swap",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"bytesize",
|
"bytesize",
|
||||||
"err-derive",
|
|
||||||
"format_table",
|
"format_table",
|
||||||
"futures",
|
"futures",
|
||||||
"garage_net",
|
"garage_net",
|
||||||
@@ -1601,6 +1586,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_bytes",
|
"serde_bytes",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"thiserror 2.0.12",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
@@ -1635,7 +1621,6 @@ dependencies = [
|
|||||||
"blake2",
|
"blake2",
|
||||||
"bytesize",
|
"bytesize",
|
||||||
"chrono",
|
"chrono",
|
||||||
"err-derive",
|
|
||||||
"futures",
|
"futures",
|
||||||
"garage_db",
|
"garage_db",
|
||||||
"garage_net",
|
"garage_net",
|
||||||
@@ -1652,6 +1637,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sha2",
|
"sha2",
|
||||||
|
"thiserror 2.0.12",
|
||||||
"tokio",
|
"tokio",
|
||||||
"toml",
|
"toml",
|
||||||
"tracing",
|
"tracing",
|
||||||
@@ -1662,7 +1648,6 @@ dependencies = [
|
|||||||
name = "garage_web"
|
name = "garage_web"
|
||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"err-derive",
|
|
||||||
"garage_api_common",
|
"garage_api_common",
|
||||||
"garage_api_s3",
|
"garage_api_s3",
|
||||||
"garage_model",
|
"garage_model",
|
||||||
@@ -1673,6 +1658,7 @@ dependencies = [
|
|||||||
"hyper 1.6.0",
|
"hyper 1.6.0",
|
||||||
"opentelemetry",
|
"opentelemetry",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
|
"thiserror 2.0.12",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
@@ -2465,7 +2451,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sha2",
|
"sha2",
|
||||||
"thiserror 1.0.69",
|
"thiserror 2.0.12",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
]
|
]
|
||||||
@@ -4282,18 +4268,6 @@ dependencies = [
|
|||||||
"crossbeam-queue",
|
"crossbeam-queue",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "synstructure"
|
|
||||||
version = "0.12.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 1.0.109",
|
|
||||||
"unicode-xid",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "synstructure"
|
name = "synstructure"
|
||||||
version = "0.13.1"
|
version = "0.13.1"
|
||||||
@@ -4813,12 +4787,6 @@ version = "0.1.14"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
|
checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-xid"
|
|
||||||
version = "0.2.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "universal-hash"
|
name = "universal-hash"
|
||||||
version = "0.5.1"
|
version = "0.5.1"
|
||||||
@@ -5344,7 +5312,7 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.100",
|
"syn 2.0.100",
|
||||||
"synstructure 0.13.1",
|
"synstructure",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -5405,7 +5373,7 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.100",
|
"syn 2.0.100",
|
||||||
"synstructure 0.13.1",
|
"synstructure",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
+1
-2
@@ -51,7 +51,6 @@ cfg-if = "1.0"
|
|||||||
chrono = { version = "0.4", features = ["serde"] }
|
chrono = { version = "0.4", features = ["serde"] }
|
||||||
crc-fast = "1.1"
|
crc-fast = "1.1"
|
||||||
crypto-common = "0.1"
|
crypto-common = "0.1"
|
||||||
err-derive = "0.3"
|
|
||||||
gethostname = "0.4"
|
gethostname = "0.4"
|
||||||
git-version = "0.3.4"
|
git-version = "0.3.4"
|
||||||
hex = "0.4"
|
hex = "0.4"
|
||||||
@@ -138,7 +137,7 @@ prometheus = "0.13"
|
|||||||
aws-sigv4 = { version = "1.1", default-features = false }
|
aws-sigv4 = { version = "1.1", default-features = false }
|
||||||
hyper-rustls = { version = "0.26", default-features = false, features = ["http1", "http2", "ring", "rustls-native-certs"] }
|
hyper-rustls = { version = "0.26", default-features = false, features = ["http1", "http2", "ring", "rustls-native-certs"] }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
thiserror = "1.0"
|
thiserror = "2.0"
|
||||||
|
|
||||||
# ---- used only as build / dev dependencies ----
|
# ---- used only as build / dev dependencies ----
|
||||||
assert-json-diff = "2.0"
|
assert-json-diff = "2.0"
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ argon2.workspace = true
|
|||||||
async-trait.workspace = true
|
async-trait.workspace = true
|
||||||
bytesize.workspace = true
|
bytesize.workspace = true
|
||||||
chrono.workspace = true
|
chrono.workspace = true
|
||||||
err-derive.workspace = true
|
thiserror.workspace = true
|
||||||
hex.workspace = true
|
hex.workspace = true
|
||||||
paste.workspace = true
|
paste.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
|
|||||||
+9
-12
@@ -1,6 +1,6 @@
|
|||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
|
||||||
use err_derive::Error;
|
use thiserror::Error;
|
||||||
use hyper::header::HeaderValue;
|
use hyper::header::HeaderValue;
|
||||||
use hyper::{HeaderMap, StatusCode};
|
use hyper::{HeaderMap, StatusCode};
|
||||||
|
|
||||||
@@ -16,36 +16,33 @@ use garage_api_common::helpers::*;
|
|||||||
/// Errors of this crate
|
/// Errors of this crate
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error(display = "{}", _0)]
|
#[error("{0}")]
|
||||||
/// Error from common error
|
/// Error from common error
|
||||||
Common(#[error(source)] CommonError),
|
Common(#[from] CommonError),
|
||||||
|
|
||||||
// Category: cannot process
|
// Category: cannot process
|
||||||
/// The admin API token does not exist
|
/// The admin API token does not exist
|
||||||
#[error(display = "Admin token not found: {}", _0)]
|
#[error("Admin token not found: {0}")]
|
||||||
NoSuchAdminToken(String),
|
NoSuchAdminToken(String),
|
||||||
|
|
||||||
/// The API access key does not exist
|
/// The API access key does not exist
|
||||||
#[error(display = "Access key not found: {}", _0)]
|
#[error("Access key not found: {00}")]
|
||||||
NoSuchAccessKey(String),
|
NoSuchAccessKey(String),
|
||||||
|
|
||||||
/// The requested block does not exist
|
/// The requested block does not exist
|
||||||
#[error(display = "Block not found: {}", _0)]
|
#[error("Block not found: {0}")]
|
||||||
NoSuchBlock(String),
|
NoSuchBlock(String),
|
||||||
|
|
||||||
/// The requested worker does not exist
|
/// The requested worker does not exist
|
||||||
#[error(display = "Worker not found: {}", _0)]
|
#[error("Worker not found: {0}")]
|
||||||
NoSuchWorker(u64),
|
NoSuchWorker(u64),
|
||||||
|
|
||||||
/// The object requested don't exists
|
/// The object requested don't exists
|
||||||
#[error(display = "Key not found")]
|
#[error("Key not found")]
|
||||||
NoSuchKey,
|
NoSuchKey,
|
||||||
|
|
||||||
/// In Import key, the key already exists
|
/// In Import key, the key already exists
|
||||||
#[error(
|
#[error("Key {0} already exists in data store. Even if it is deleted, we can't let you create a new key with the same ID. Sorry.")]
|
||||||
display = "Key {} already exists in data store. Even if it is deleted, we can't let you create a new key with the same ID. Sorry.",
|
|
||||||
_0
|
|
||||||
)]
|
|
||||||
KeyAlreadyExists(String),
|
KeyAlreadyExists(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ bytes.workspace = true
|
|||||||
chrono.workspace = true
|
chrono.workspace = true
|
||||||
crc-fast.workspace = true
|
crc-fast.workspace = true
|
||||||
crypto-common.workspace = true
|
crypto-common.workspace = true
|
||||||
err-derive.workspace = true
|
thiserror.workspace = true
|
||||||
hex.workspace = true
|
hex.workspace = true
|
||||||
hmac.workspace = true
|
hmac.workspace = true
|
||||||
md-5.workspace = true
|
md-5.workspace = true
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
|
||||||
use err_derive::Error;
|
use thiserror::Error;
|
||||||
use hyper::StatusCode;
|
use hyper::StatusCode;
|
||||||
|
|
||||||
use garage_util::error::Error as GarageError;
|
use garage_util::error::Error as GarageError;
|
||||||
@@ -12,48 +12,48 @@ use garage_model::helper::error::Error as HelperError;
|
|||||||
pub enum CommonError {
|
pub enum CommonError {
|
||||||
// ---- INTERNAL ERRORS ----
|
// ---- INTERNAL ERRORS ----
|
||||||
/// Error related to deeper parts of Garage
|
/// Error related to deeper parts of Garage
|
||||||
#[error(display = "Internal error: {}", _0)]
|
#[error("Internal error: {0}")]
|
||||||
InternalError(#[error(source)] GarageError),
|
InternalError(#[from] GarageError),
|
||||||
|
|
||||||
/// Error related to Hyper
|
/// Error related to Hyper
|
||||||
#[error(display = "Internal error (Hyper error): {}", _0)]
|
#[error("Internal error (Hyper error): {0}")]
|
||||||
Hyper(#[error(source)] hyper::Error),
|
Hyper(#[from] hyper::Error),
|
||||||
|
|
||||||
/// Error related to HTTP
|
/// Error related to HTTP
|
||||||
#[error(display = "Internal error (HTTP error): {}", _0)]
|
#[error("Internal error (HTTP error): {0}")]
|
||||||
Http(#[error(source)] http::Error),
|
Http(#[from] http::Error),
|
||||||
|
|
||||||
// ---- GENERIC CLIENT ERRORS ----
|
// ---- GENERIC CLIENT ERRORS ----
|
||||||
/// Proper authentication was not provided
|
/// Proper authentication was not provided
|
||||||
#[error(display = "Forbidden: {}", _0)]
|
#[error("Forbidden: {0}")]
|
||||||
Forbidden(String),
|
Forbidden(String),
|
||||||
|
|
||||||
/// Generic bad request response with custom message
|
/// Generic bad request response with custom message
|
||||||
#[error(display = "Bad request: {}", _0)]
|
#[error("Bad request: {0}")]
|
||||||
BadRequest(String),
|
BadRequest(String),
|
||||||
|
|
||||||
/// The client sent a header with invalid value
|
/// The client sent a header with invalid value
|
||||||
#[error(display = "Invalid header value: {}", _0)]
|
#[error("Invalid header value: {0}")]
|
||||||
InvalidHeader(#[error(source)] hyper::header::ToStrError),
|
InvalidHeader(#[from] hyper::header::ToStrError),
|
||||||
|
|
||||||
// ---- SPECIFIC ERROR CONDITIONS ----
|
// ---- SPECIFIC ERROR CONDITIONS ----
|
||||||
// These have to be error codes referenced in the S3 spec here:
|
// These have to be error codes referenced in the S3 spec here:
|
||||||
// https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html#ErrorCodeList
|
// https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html#ErrorCodeList
|
||||||
/// The bucket requested don't exists
|
/// The bucket requested don't exists
|
||||||
#[error(display = "Bucket not found: {}", _0)]
|
#[error("Bucket not found: {0}")]
|
||||||
NoSuchBucket(String),
|
NoSuchBucket(String),
|
||||||
|
|
||||||
/// Tried to create a bucket that already exist
|
/// Tried to create a bucket that already exist
|
||||||
#[error(display = "Bucket already exists")]
|
#[error("Bucket already exists")]
|
||||||
BucketAlreadyExists,
|
BucketAlreadyExists,
|
||||||
|
|
||||||
/// Tried to delete a non-empty bucket
|
/// Tried to delete a non-empty bucket
|
||||||
#[error(display = "Tried to delete a non-empty bucket")]
|
#[error("Tried to delete a non-empty bucket")]
|
||||||
BucketNotEmpty,
|
BucketNotEmpty,
|
||||||
|
|
||||||
// Category: bad request
|
// Category: bad request
|
||||||
/// Bucket name is not valid according to AWS S3 specs
|
/// Bucket name is not valid according to AWS S3 specs
|
||||||
#[error(display = "Invalid bucket name: {}", _0)]
|
#[error("Invalid bucket name: {0}")]
|
||||||
InvalidBucketName(String),
|
InvalidBucketName(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use err_derive::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::common_error::CommonError;
|
use crate::common_error::CommonError;
|
||||||
pub use crate::common_error::{CommonErrorDerivative, OkOrBadRequest, OkOrInternalError};
|
pub use crate::common_error::{CommonErrorDerivative, OkOrBadRequest, OkOrInternalError};
|
||||||
@@ -6,21 +6,21 @@ pub use crate::common_error::{CommonErrorDerivative, OkOrBadRequest, OkOrInterna
|
|||||||
/// Errors of this crate
|
/// Errors of this crate
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error(display = "{}", _0)]
|
#[error("{0}")]
|
||||||
/// Error from common error
|
/// Error from common error
|
||||||
Common(CommonError),
|
Common(CommonError),
|
||||||
|
|
||||||
/// Authorization Header Malformed
|
/// Authorization Header Malformed
|
||||||
#[error(display = "Authorization header malformed, unexpected scope: {}", _0)]
|
#[error("Authorization header malformed, unexpected scope: {0}")]
|
||||||
AuthorizationHeaderMalformed(String),
|
AuthorizationHeaderMalformed(String),
|
||||||
|
|
||||||
// Category: bad request
|
// Category: bad request
|
||||||
/// The request contained an invalid UTF-8 sequence in its path or in other parameters
|
/// The request contained an invalid UTF-8 sequence in its path or in other parameters
|
||||||
#[error(display = "Invalid UTF-8: {}", _0)]
|
#[error("Invalid UTF-8: {0}")]
|
||||||
InvalidUtf8Str(#[error(source)] std::str::Utf8Error),
|
InvalidUtf8Str(#[from] std::str::Utf8Error),
|
||||||
|
|
||||||
/// The provided digest (checksum) value was invalid
|
/// The provided digest (checksum) value was invalid
|
||||||
#[error(display = "Invalid digest: {}", _0)]
|
#[error("Invalid digest: {0}")]
|
||||||
InvalidDigest(String),
|
InvalidDigest(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ garage_util = { workspace = true, features = [ "k2v" ] }
|
|||||||
garage_api_common.workspace = true
|
garage_api_common.workspace = true
|
||||||
|
|
||||||
base64.workspace = true
|
base64.workspace = true
|
||||||
err-derive.workspace = true
|
thiserror.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
|
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
|
|||||||
+12
-12
@@ -1,4 +1,4 @@
|
|||||||
use err_derive::Error;
|
use thiserror::Error;
|
||||||
use hyper::header::HeaderValue;
|
use hyper::header::HeaderValue;
|
||||||
use hyper::{HeaderMap, StatusCode};
|
use hyper::{HeaderMap, StatusCode};
|
||||||
|
|
||||||
@@ -14,38 +14,38 @@ use garage_api_common::signature::error::Error as SignatureError;
|
|||||||
/// Errors of this crate
|
/// Errors of this crate
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error(display = "{}", _0)]
|
#[error("{0}")]
|
||||||
/// Error from common error
|
/// Error from common error
|
||||||
Common(#[error(source)] CommonError),
|
Common(#[from] CommonError),
|
||||||
|
|
||||||
// Category: cannot process
|
// Category: cannot process
|
||||||
/// Authorization Header Malformed
|
/// Authorization Header Malformed
|
||||||
#[error(display = "Authorization header malformed, unexpected scope: {}", _0)]
|
#[error("Authorization header malformed, unexpected scope: {0}")]
|
||||||
AuthorizationHeaderMalformed(String),
|
AuthorizationHeaderMalformed(String),
|
||||||
|
|
||||||
/// The provided digest (checksum) value was invalid
|
/// The provided digest (checksum) value was invalid
|
||||||
#[error(display = "Invalid digest: {}", _0)]
|
#[error("Invalid digest: {0}")]
|
||||||
InvalidDigest(String),
|
InvalidDigest(String),
|
||||||
|
|
||||||
/// The object requested don't exists
|
/// The object requested don't exists
|
||||||
#[error(display = "Key not found")]
|
#[error("Key not found")]
|
||||||
NoSuchKey,
|
NoSuchKey,
|
||||||
|
|
||||||
/// Some base64 encoded data was badly encoded
|
/// Some base64 encoded data was badly encoded
|
||||||
#[error(display = "Invalid base64: {}", _0)]
|
#[error("Invalid base64: {0}")]
|
||||||
InvalidBase64(#[error(source)] base64::DecodeError),
|
InvalidBase64(#[from] base64::DecodeError),
|
||||||
|
|
||||||
/// Invalid causality token
|
/// Invalid causality token
|
||||||
#[error(display = "Invalid causality token")]
|
#[error("Invalid causality token")]
|
||||||
InvalidCausalityToken,
|
InvalidCausalityToken,
|
||||||
|
|
||||||
/// The client asked for an invalid return format (invalid Accept header)
|
/// The client asked for an invalid return format (invalid Accept header)
|
||||||
#[error(display = "Not acceptable: {}", _0)]
|
#[error("Not acceptable: {0}")]
|
||||||
NotAcceptable(String),
|
NotAcceptable(String),
|
||||||
|
|
||||||
/// The request contained an invalid UTF-8 sequence in its path or in other parameters
|
/// The request contained an invalid UTF-8 sequence in its path or in other parameters
|
||||||
#[error(display = "Invalid UTF-8: {}", _0)]
|
#[error("Invalid UTF-8: {0}")]
|
||||||
InvalidUtf8Str(#[error(source)] std::str::Utf8Error),
|
InvalidUtf8Str(#[from] std::str::Utf8Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
commonErrorDerivative!(Error);
|
commonErrorDerivative!(Error);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ base64.workspace = true
|
|||||||
bytes.workspace = true
|
bytes.workspace = true
|
||||||
chrono.workspace = true
|
chrono.workspace = true
|
||||||
crc-fast.workspace = true
|
crc-fast.workspace = true
|
||||||
err-derive.workspace = true
|
thiserror.workspace = true
|
||||||
hex.workspace = true
|
hex.workspace = true
|
||||||
hmac.workspace = true
|
hmac.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
|
|||||||
+26
-20
@@ -1,6 +1,6 @@
|
|||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
use err_derive::Error;
|
use thiserror::Error;
|
||||||
use hyper::header::HeaderValue;
|
use hyper::header::HeaderValue;
|
||||||
use hyper::{HeaderMap, StatusCode};
|
use hyper::{HeaderMap, StatusCode};
|
||||||
|
|
||||||
@@ -25,67 +25,67 @@ use crate::xml as s3_xml;
|
|||||||
/// Errors of this crate
|
/// Errors of this crate
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error(display = "{}", _0)]
|
#[error("{0}")]
|
||||||
/// Error from common error
|
/// Error from common error
|
||||||
Common(#[error(source)] CommonError),
|
Common(#[from] CommonError),
|
||||||
|
|
||||||
// Category: cannot process
|
// Category: cannot process
|
||||||
/// Authorization Header Malformed
|
/// Authorization Header Malformed
|
||||||
#[error(display = "Authorization header malformed, unexpected scope: {}", _0)]
|
#[error("Authorization header malformed, unexpected scope: {0}")]
|
||||||
AuthorizationHeaderMalformed(String),
|
AuthorizationHeaderMalformed(String),
|
||||||
|
|
||||||
/// The object requested don't exists
|
/// The object requested don't exists
|
||||||
#[error(display = "Key not found")]
|
#[error("Key not found")]
|
||||||
NoSuchKey,
|
NoSuchKey,
|
||||||
|
|
||||||
/// The multipart upload requested don't exists
|
/// The multipart upload requested don't exists
|
||||||
#[error(display = "Upload not found")]
|
#[error("Upload not found")]
|
||||||
NoSuchUpload,
|
NoSuchUpload,
|
||||||
|
|
||||||
/// Precondition failed (e.g. x-amz-copy-source-if-match)
|
/// Precondition failed (e.g. x-amz-copy-source-if-match)
|
||||||
#[error(display = "At least one of the preconditions you specified did not hold")]
|
#[error("At least one of the preconditions you specified did not hold")]
|
||||||
PreconditionFailed,
|
PreconditionFailed,
|
||||||
|
|
||||||
/// Parts specified in CMU request do not match parts actually uploaded
|
/// Parts specified in CMU request do not match parts actually uploaded
|
||||||
#[error(display = "Parts given to CompleteMultipartUpload do not match uploaded parts")]
|
#[error("Parts given to CompleteMultipartUpload do not match uploaded parts")]
|
||||||
InvalidPart,
|
InvalidPart,
|
||||||
|
|
||||||
/// Parts given to CompleteMultipartUpload were not in ascending order
|
/// Parts given to CompleteMultipartUpload were not in ascending order
|
||||||
#[error(display = "Parts given to CompleteMultipartUpload were not in ascending order")]
|
#[error("Parts given to CompleteMultipartUpload were not in ascending order")]
|
||||||
InvalidPartOrder,
|
InvalidPartOrder,
|
||||||
|
|
||||||
/// In CompleteMultipartUpload: not enough data
|
/// In CompleteMultipartUpload: not enough data
|
||||||
/// (here we are more lenient than AWS S3)
|
/// (here we are more lenient than AWS S3)
|
||||||
#[error(display = "Proposed upload is smaller than the minimum allowed object size")]
|
#[error("Proposed upload is smaller than the minimum allowed object size")]
|
||||||
EntityTooSmall,
|
EntityTooSmall,
|
||||||
|
|
||||||
// Category: bad request
|
// Category: bad request
|
||||||
/// The request contained an invalid UTF-8 sequence in its path or in other parameters
|
/// The request contained an invalid UTF-8 sequence in its path or in other parameters
|
||||||
#[error(display = "Invalid UTF-8: {}", _0)]
|
#[error("Invalid UTF-8: {0}")]
|
||||||
InvalidUtf8Str(#[error(source)] std::str::Utf8Error),
|
InvalidUtf8Str(#[from] std::str::Utf8Error),
|
||||||
|
|
||||||
/// The request used an invalid path
|
/// The request used an invalid path
|
||||||
#[error(display = "Invalid UTF-8: {}", _0)]
|
#[error("Invalid UTF-8: {0}")]
|
||||||
InvalidUtf8String(#[error(source)] std::string::FromUtf8Error),
|
InvalidUtf8String(#[from] std::string::FromUtf8Error),
|
||||||
|
|
||||||
/// The client sent invalid XML data
|
/// The client sent invalid XML data
|
||||||
#[error(display = "Invalid XML: {}", _0)]
|
#[error("Invalid XML: {0}")]
|
||||||
InvalidXml(String),
|
InvalidXml(String),
|
||||||
|
|
||||||
/// The client sent a range header with invalid value
|
/// The client sent a range header with invalid value
|
||||||
#[error(display = "Invalid HTTP range: {:?}", _0)]
|
#[error("Invalid HTTP range: {0:?}")]
|
||||||
InvalidRange(#[error(from)] (http_range::HttpRangeParseError, u64)),
|
InvalidRange((http_range::HttpRangeParseError, u64)),
|
||||||
|
|
||||||
/// The client sent a range header with invalid value
|
/// The client sent a range header with invalid value
|
||||||
#[error(display = "Invalid encryption algorithm: {:?}, should be AES256", _0)]
|
#[error("Invalid encryption algorithm: {0:?}, should be AES256")]
|
||||||
InvalidEncryptionAlgorithm(String),
|
InvalidEncryptionAlgorithm(String),
|
||||||
|
|
||||||
/// The provided digest (checksum) value was invalid
|
/// The provided digest (checksum) value was invalid
|
||||||
#[error(display = "Invalid digest: {}", _0)]
|
#[error("Invalid digest: {0}")]
|
||||||
InvalidDigest(String),
|
InvalidDigest(String),
|
||||||
|
|
||||||
/// The client sent a request for an action not supported by garage
|
/// The client sent a request for an action not supported by garage
|
||||||
#[error(display = "Unimplemented action: {}", _0)]
|
#[error("Unimplemented action: {0}")]
|
||||||
NotImplemented(String),
|
NotImplemented(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,6 +99,12 @@ impl From<HelperError> for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<(http_range::HttpRangeParseError, u64)> for Error {
|
||||||
|
fn from (err: (http_range::HttpRangeParseError, u64)) -> Error {
|
||||||
|
Error::InvalidRange(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<roxmltree::Error> for Error {
|
impl From<roxmltree::Error> for Error {
|
||||||
fn from(err: roxmltree::Error) -> Self {
|
fn from(err: roxmltree::Error) -> Self {
|
||||||
Self::InvalidXml(format!("{}", err))
|
Self::InvalidXml(format!("{}", err))
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ readme = "../../README.md"
|
|||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
err-derive.workspace = true
|
thiserror.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
|
|
||||||
heed = { workspace = true, optional = true }
|
heed = { workspace = true, optional = true }
|
||||||
|
|||||||
+3
-3
@@ -20,7 +20,7 @@ use std::cell::Cell;
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use err_derive::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
pub use open::*;
|
pub use open::*;
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ pub type TxValueIter<'a> = Box<dyn std::iter::Iterator<Item = TxOpResult<(Value,
|
|||||||
// ----
|
// ----
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
#[error(display = "{}", _0)]
|
#[error("{0}")]
|
||||||
pub struct Error(pub Cow<'static, str>);
|
pub struct Error(pub Cow<'static, str>);
|
||||||
|
|
||||||
impl From<std::io::Error> for Error {
|
impl From<std::io::Error> for Error {
|
||||||
@@ -56,7 +56,7 @@ impl From<std::io::Error> for Error {
|
|||||||
pub type Result<T> = std::result::Result<T, Error>;
|
pub type Result<T> = std::result::Result<T, Error>;
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
#[error(display = "{}", _0)]
|
#[error("{0}")]
|
||||||
pub struct TxOpError(pub(crate) Error);
|
pub struct TxOpError(pub(crate) Error);
|
||||||
pub type TxOpResult<T> = std::result::Result<T, TxOpError>;
|
pub type TxOpResult<T> = std::result::Result<T, TxOpError>;
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ argon2.workspace = true
|
|||||||
async-trait.workspace = true
|
async-trait.workspace = true
|
||||||
blake2.workspace = true
|
blake2.workspace = true
|
||||||
chrono.workspace = true
|
chrono.workspace = true
|
||||||
err-derive.workspace = true
|
thiserror.workspace = true
|
||||||
hex.workspace = true
|
hex.workspace = true
|
||||||
http.workspace = true
|
http.workspace = true
|
||||||
base64.workspace = true
|
base64.workspace = true
|
||||||
|
|||||||
+3
-3
@@ -321,15 +321,15 @@ impl Garage {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bucket_helper(&self) -> helper::bucket::BucketHelper {
|
pub fn bucket_helper(&self) -> helper::bucket::BucketHelper<'_> {
|
||||||
helper::bucket::BucketHelper(self)
|
helper::bucket::BucketHelper(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn key_helper(&self) -> helper::key::KeyHelper {
|
pub fn key_helper(&self) -> helper::key::KeyHelper<'_> {
|
||||||
helper::key::KeyHelper(self)
|
helper::key::KeyHelper(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn locked_helper(&self) -> helper::locked::LockedHelper {
|
pub async fn locked_helper(&self) -> helper::locked::LockedHelper<'_> {
|
||||||
let lock = self.bucket_lock.lock().await;
|
let lock = self.bucket_lock.lock().await;
|
||||||
helper::locked::LockedHelper(self, Some(lock))
|
helper::locked::LockedHelper(self, Some(lock))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
use err_derive::Error;
|
use thiserror::Error;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use garage_util::error::Error as GarageError;
|
use garage_util::error::Error as GarageError;
|
||||||
|
|
||||||
#[derive(Debug, Error, Serialize, Deserialize)]
|
#[derive(Debug, Error, Serialize, Deserialize)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error(display = "Internal error: {}", _0)]
|
#[error("Internal error: {0}")]
|
||||||
Internal(#[error(source)] GarageError),
|
Internal(#[from] GarageError),
|
||||||
|
|
||||||
#[error(display = "Bad request: {}", _0)]
|
#[error("Bad request: {0}")]
|
||||||
BadRequest(String),
|
BadRequest(String),
|
||||||
|
|
||||||
/// Bucket name is not valid according to AWS S3 specs
|
/// Bucket name is not valid according to AWS S3 specs
|
||||||
#[error(display = "Invalid bucket name: {}", _0)]
|
#[error("Invalid bucket name: {0}")]
|
||||||
InvalidBucketName(String),
|
InvalidBucketName(String),
|
||||||
|
|
||||||
#[error(display = "Access key not found: {}", _0)]
|
#[error("Access key not found: {0}")]
|
||||||
NoSuchAccessKey(String),
|
NoSuchAccessKey(String),
|
||||||
|
|
||||||
#[error(display = "Bucket not found: {}", _0)]
|
#[error("Bucket not found: {0}")]
|
||||||
NoSuchBucket(String),
|
NoSuchBucket(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ rand.workspace = true
|
|||||||
|
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
arc-swap.workspace = true
|
arc-swap.workspace = true
|
||||||
err-derive.workspace = true
|
thiserror.workspace = true
|
||||||
bytes.workspace = true
|
bytes.workspace = true
|
||||||
cfg-if.workspace = true
|
cfg-if.workspace = true
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -159,7 +159,7 @@ where
|
|||||||
pub(crate) type DynEndpoint = Box<dyn GenericEndpoint + Send + Sync>;
|
pub(crate) type DynEndpoint = Box<dyn GenericEndpoint + Send + Sync>;
|
||||||
|
|
||||||
pub(crate) trait GenericEndpoint {
|
pub(crate) trait GenericEndpoint {
|
||||||
fn handle(&self, req_enc: ReqEnc, from: NodeID) -> BoxFuture<Result<RespEnc, Error>>;
|
fn handle(&self, req_enc: ReqEnc, from: NodeID) -> BoxFuture<'_, Result<RespEnc, Error>>;
|
||||||
fn drop_handler(&self);
|
fn drop_handler(&self);
|
||||||
fn clone_endpoint(&self) -> DynEndpoint;
|
fn clone_endpoint(&self) -> DynEndpoint;
|
||||||
}
|
}
|
||||||
@@ -175,7 +175,7 @@ where
|
|||||||
M: Message,
|
M: Message,
|
||||||
H: StreamingEndpointHandler<M> + 'static,
|
H: StreamingEndpointHandler<M> + 'static,
|
||||||
{
|
{
|
||||||
fn handle(&self, req_enc: ReqEnc, from: NodeID) -> BoxFuture<Result<RespEnc, Error>> {
|
fn handle(&self, req_enc: ReqEnc, from: NodeID) -> BoxFuture<'_, Result<RespEnc, Error>> {
|
||||||
async move {
|
async move {
|
||||||
match self.0.handler.load_full() {
|
match self.0.handler.load_full() {
|
||||||
None => Err(Error::NoHandler),
|
None => Err(Error::NoHandler),
|
||||||
|
|||||||
+22
-22
@@ -1,49 +1,49 @@
|
|||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use err_derive::Error;
|
use thiserror::Error;
|
||||||
use log::error;
|
use log::error;
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error(display = "IO error: {}", _0)]
|
#[error("IO error: {0}")]
|
||||||
Io(#[error(source)] io::Error),
|
Io(#[from] io::Error),
|
||||||
|
|
||||||
#[error(display = "Messagepack encode error: {}", _0)]
|
#[error("Messagepack encode error: {0}")]
|
||||||
RMPEncode(#[error(source)] rmp_serde::encode::Error),
|
RMPEncode(#[from] rmp_serde::encode::Error),
|
||||||
#[error(display = "Messagepack decode error: {}", _0)]
|
#[error("Messagepack decode error: {0}")]
|
||||||
RMPDecode(#[error(source)] rmp_serde::decode::Error),
|
RMPDecode(#[from] rmp_serde::decode::Error),
|
||||||
|
|
||||||
#[error(display = "Tokio join error: {}", _0)]
|
#[error("Tokio join error: {0}")]
|
||||||
TokioJoin(#[error(source)] tokio::task::JoinError),
|
TokioJoin(#[from] tokio::task::JoinError),
|
||||||
|
|
||||||
#[error(display = "oneshot receive error: {}", _0)]
|
#[error("oneshot receive error: {0}")]
|
||||||
OneshotRecv(#[error(source)] tokio::sync::oneshot::error::RecvError),
|
OneshotRecv(#[from] tokio::sync::oneshot::error::RecvError),
|
||||||
|
|
||||||
#[error(display = "Handshake error: {}", _0)]
|
#[error("Handshake error: {0}")]
|
||||||
Handshake(#[error(source)] kuska_handshake::async_std::Error),
|
Handshake(#[from] kuska_handshake::async_std::Error),
|
||||||
|
|
||||||
#[error(display = "UTF8 error: {}", _0)]
|
#[error("UTF8 error: {0}")]
|
||||||
UTF8(#[error(source)] std::string::FromUtf8Error),
|
UTF8(#[from] std::string::FromUtf8Error),
|
||||||
|
|
||||||
#[error(display = "Framing protocol error")]
|
#[error("Framing protocol error")]
|
||||||
Framing,
|
Framing,
|
||||||
|
|
||||||
#[error(display = "Remote error ({:?}): {}", _0, _1)]
|
#[error("Remote error ({0:?}): {1}")]
|
||||||
Remote(io::ErrorKind, String),
|
Remote(io::ErrorKind, String),
|
||||||
|
|
||||||
#[error(display = "Request ID collision")]
|
#[error("Request ID collision")]
|
||||||
IdCollision,
|
IdCollision,
|
||||||
|
|
||||||
#[error(display = "{}", _0)]
|
#[error("{0}")]
|
||||||
Message(String),
|
Message(String),
|
||||||
|
|
||||||
#[error(display = "No handler / shutting down")]
|
#[error("No handler / shutting down")]
|
||||||
NoHandler,
|
NoHandler,
|
||||||
|
|
||||||
#[error(display = "Connection closed")]
|
#[error("Connection closed")]
|
||||||
ConnectionClosed,
|
ConnectionClosed,
|
||||||
|
|
||||||
#[error(display = "Version mismatch: {}", _0)]
|
#[error("Version mismatch: {0}")]
|
||||||
VersionMismatch(String),
|
VersionMismatch(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -33,7 +33,7 @@ async-trait.workspace = true
|
|||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_bytes.workspace = true
|
serde_bytes.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
err-derive = { workspace = true, optional = true }
|
thiserror = { workspace = true, optional = true }
|
||||||
|
|
||||||
# newer version requires rust edition 2021
|
# newer version requires rust edition 2021
|
||||||
kube = { workspace = true, optional = true }
|
kube = { workspace = true, optional = true }
|
||||||
@@ -49,5 +49,5 @@ opentelemetry.workspace = true
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
kubernetes-discovery = [ "kube", "k8s-openapi", "schemars" ]
|
kubernetes-discovery = [ "kube", "k8s-openapi", "schemars" ]
|
||||||
consul-discovery = [ "reqwest", "err-derive" ]
|
consul-discovery = [ "reqwest", "thiserror" ]
|
||||||
system-libs = [ "sodiumoxide/use-pkg-config" ]
|
system-libs = [ "sodiumoxide/use-pkg-config" ]
|
||||||
|
|||||||
+8
-8
@@ -3,7 +3,7 @@ use std::fs::File;
|
|||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::net::{IpAddr, SocketAddr};
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
use err_derive::Error;
|
use thiserror::Error;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use garage_net::NodeID;
|
use garage_net::NodeID;
|
||||||
@@ -219,12 +219,12 @@ impl ConsulDiscovery {
|
|||||||
/// Regroup all Consul discovery errors
|
/// Regroup all Consul discovery errors
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum ConsulError {
|
pub enum ConsulError {
|
||||||
#[error(display = "IO error: {}", _0)]
|
#[error("IO error: {0}")]
|
||||||
Io(#[error(source)] std::io::Error),
|
Io(#[from] std::io::Error),
|
||||||
#[error(display = "HTTP error: {}", _0)]
|
#[error("HTTP error: {0}")]
|
||||||
Reqwest(#[error(source)] reqwest::Error),
|
Reqwest(#[from] reqwest::Error),
|
||||||
#[error(display = "Invalid Consul TLS configuration")]
|
#[error("Invalid Consul TLS configuration")]
|
||||||
InvalidTLSConfig,
|
InvalidTLSConfig,
|
||||||
#[error(display = "Token error: {}", _0)]
|
#[error("Token error: {0}")]
|
||||||
Token(#[error(source)] reqwest::header::InvalidHeaderValue),
|
Token(#[from] reqwest::header::InvalidHeaderValue),
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ arc-swap.workspace = true
|
|||||||
async-trait.workspace = true
|
async-trait.workspace = true
|
||||||
blake2.workspace = true
|
blake2.workspace = true
|
||||||
bytesize.workspace = true
|
bytesize.workspace = true
|
||||||
err-derive.workspace = true
|
thiserror.workspace = true
|
||||||
hexdump.workspace = true
|
hexdump.workspace = true
|
||||||
xxhash-rust.workspace = true
|
xxhash-rust.workspace = true
|
||||||
hex.workspace = true
|
hex.workspace = true
|
||||||
|
|||||||
+35
-42
@@ -2,7 +2,7 @@
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use err_derive::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
|
||||||
@@ -12,71 +12,64 @@ use crate::encode::debug_serialize;
|
|||||||
/// Regroup all Garage errors
|
/// Regroup all Garage errors
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error(display = "IO error: {}", _0)]
|
#[error("IO error: {0}")]
|
||||||
Io(#[error(source)] io::Error),
|
Io(#[from] io::Error),
|
||||||
|
|
||||||
#[error(display = "Hyper error: {}", _0)]
|
#[error("Hyper error: {0}")]
|
||||||
Hyper(#[error(source)] hyper::Error),
|
Hyper(#[from] hyper::Error),
|
||||||
|
|
||||||
#[error(display = "HTTP error: {}", _0)]
|
#[error("HTTP error: {0}")]
|
||||||
Http(#[error(source)] http::Error),
|
Http(#[from] http::Error),
|
||||||
|
|
||||||
#[error(display = "Invalid HTTP header value: {}", _0)]
|
#[error("Invalid HTTP header value: {0}")]
|
||||||
HttpHeader(#[error(source)] http::header::ToStrError),
|
HttpHeader(#[from] http::header::ToStrError),
|
||||||
|
|
||||||
#[error(display = "Network error: {}", _0)]
|
#[error("Network error: {0}")]
|
||||||
Net(#[error(source)] garage_net::error::Error),
|
Net(#[from] garage_net::error::Error),
|
||||||
|
|
||||||
#[error(display = "DB error: {}", _0)]
|
#[error("DB error: {0}")]
|
||||||
Db(#[error(source)] garage_db::Error),
|
Db(#[from] garage_db::Error),
|
||||||
|
|
||||||
#[error(display = "Messagepack encode error: {}", _0)]
|
#[error("Messagepack encode error: {0}")]
|
||||||
RmpEncode(#[error(source)] rmp_serde::encode::Error),
|
RmpEncode(#[from] rmp_serde::encode::Error),
|
||||||
#[error(display = "Messagepack decode error: {}", _0)]
|
#[error("Messagepack decode error: {0}")]
|
||||||
RmpDecode(#[error(source)] rmp_serde::decode::Error),
|
RmpDecode(#[from] rmp_serde::decode::Error),
|
||||||
#[error(display = "JSON error: {}", _0)]
|
#[error("JSON error: {0}")]
|
||||||
Json(#[error(source)] serde_json::error::Error),
|
Json(#[from] serde_json::error::Error),
|
||||||
#[error(display = "TOML decode error: {}", _0)]
|
#[error("TOML decode error: {0}")]
|
||||||
TomlDecode(#[error(source)] toml::de::Error),
|
TomlDecode(#[from] toml::de::Error),
|
||||||
|
|
||||||
#[error(display = "Tokio join error: {}", _0)]
|
#[error("Tokio join error: {0}")]
|
||||||
TokioJoin(#[error(source)] tokio::task::JoinError),
|
TokioJoin(#[from] tokio::task::JoinError),
|
||||||
|
|
||||||
#[error(display = "Tokio semaphore acquire error: {}", _0)]
|
#[error("Tokio semaphore acquire error: {0}")]
|
||||||
TokioSemAcquire(#[error(source)] tokio::sync::AcquireError),
|
TokioSemAcquire(#[from] tokio::sync::AcquireError),
|
||||||
|
|
||||||
#[error(display = "Tokio broadcast receive error: {}", _0)]
|
#[error("Tokio broadcast receive error: {0}")]
|
||||||
TokioBcastRecv(#[error(source)] tokio::sync::broadcast::error::RecvError),
|
TokioBcastRecv(#[from] tokio::sync::broadcast::error::RecvError),
|
||||||
|
|
||||||
#[error(display = "Remote error: {}", _0)]
|
#[error("Remote error: {0}")]
|
||||||
RemoteError(String),
|
RemoteError(String),
|
||||||
|
|
||||||
#[error(display = "Timeout")]
|
#[error("Timeout")]
|
||||||
Timeout,
|
Timeout,
|
||||||
|
|
||||||
#[error(display = "Layout not ready")]
|
#[error("Layout not ready")]
|
||||||
LayoutNotReady,
|
LayoutNotReady,
|
||||||
|
|
||||||
#[error(
|
#[error("Could not reach quorum of {0} (sets={1:?}). {2} of {3} request succeeded, others returned errors: {4:?}")]
|
||||||
display = "Could not reach quorum of {} (sets={:?}). {} of {} request succeeded, others returned errors: {:?}",
|
|
||||||
_0,
|
|
||||||
_1,
|
|
||||||
_2,
|
|
||||||
_3,
|
|
||||||
_4
|
|
||||||
)]
|
|
||||||
Quorum(usize, Option<usize>, usize, usize, Vec<String>),
|
Quorum(usize, Option<usize>, usize, usize, Vec<String>),
|
||||||
|
|
||||||
#[error(display = "Unexpected RPC message: {}", _0)]
|
#[error("Unexpected RPC message: {0}")]
|
||||||
UnexpectedRpcMessage(String),
|
UnexpectedRpcMessage(String),
|
||||||
|
|
||||||
#[error(display = "Corrupt data: does not match hash {:?}", _0)]
|
#[error("Corrupt data: does not match hash {0:?}")]
|
||||||
CorruptData(Hash),
|
CorruptData(Hash),
|
||||||
|
|
||||||
#[error(display = "Missing block {:?}: no node returned a valid block", _0)]
|
#[error("Missing block {0:?}: no node returned a valid block")]
|
||||||
MissingBlock(Hash),
|
MissingBlock(Hash),
|
||||||
|
|
||||||
#[error(display = "{}", _0)]
|
#[error("{0}")]
|
||||||
Message(String),
|
Message(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ garage_model.workspace = true
|
|||||||
garage_util.workspace = true
|
garage_util.workspace = true
|
||||||
garage_table.workspace = true
|
garage_table.workspace = true
|
||||||
|
|
||||||
err-derive.workspace = true
|
thiserror.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
percent-encoding.workspace = true
|
percent-encoding.workspace = true
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -1,4 +1,4 @@
|
|||||||
use err_derive::Error;
|
use thiserror::Error;
|
||||||
use hyper::header::HeaderValue;
|
use hyper::header::HeaderValue;
|
||||||
use hyper::{HeaderMap, StatusCode};
|
use hyper::{HeaderMap, StatusCode};
|
||||||
|
|
||||||
@@ -8,15 +8,15 @@ use garage_api_common::generic_server::ApiError;
|
|||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// An error received from the API crate
|
/// An error received from the API crate
|
||||||
#[error(display = "API error: {}", _0)]
|
#[error("API error: {0}")]
|
||||||
ApiError(garage_api_s3::error::Error),
|
ApiError(garage_api_s3::error::Error),
|
||||||
|
|
||||||
/// The file does not exist
|
/// The file does not exist
|
||||||
#[error(display = "Not found")]
|
#[error("Not found")]
|
||||||
NotFound,
|
NotFound,
|
||||||
|
|
||||||
/// The client sent a request without host, or with unsupported method
|
/// The client sent a request without host, or with unsupported method
|
||||||
#[error(display = "Bad request: {}", _0)]
|
#[error("Bad request: {0}")]
|
||||||
BadRequest(String),
|
BadRequest(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user