aboutsummaryrefslogtreecommitdiff
path: root/src/api/error.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-01-11 12:43:46 +0100
committerAlex Auvolat <alex@adnab.me>2022-01-13 13:56:55 +0100
commit3770a34e3d3e861c91f60ec6e997f47a746c0040 (patch)
tree67c67c681ee928861a086271f047bb4ac9f447fd /src/api/error.rs
parentb4592a00fee3504b80aab9a8ee46bbacf7612e4a (diff)
downloadgarage-3770a34e3d3e861c91f60ec6e997f47a746c0040.tar.gz
garage-3770a34e3d3e861c91f60ec6e997f47a746c0040.zip
Implement x-amz-copy-if-xxx copy preconditions and return more headers on copy (fix #187)
Diffstat (limited to 'src/api/error.rs')
-rw-r--r--src/api/error.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/api/error.rs b/src/api/error.rs
index c19c4f3b..955faed1 100644
--- a/src/api/error.rs
+++ b/src/api/error.rs
@@ -54,6 +54,10 @@ pub enum Error {
#[error(display = "Tried to delete a non-empty bucket")]
BucketNotEmpty,
+ /// Precondition failed (e.g. x-amz-copy-source-if-match)
+ #[error(display = "At least one of the preconditions you specified did not hold")]
+ PreconditionFailed,
+
// Category: bad request
/// The request contained an invalid UTF-8 sequence in its path or in other parameters
#[error(display = "Invalid UTF-8: {}", _0)]
@@ -115,6 +119,7 @@ impl Error {
match self {
Error::NoSuchKey | Error::NoSuchBucket | Error::NoSuchUpload => StatusCode::NOT_FOUND,
Error::BucketNotEmpty | Error::BucketAlreadyExists => StatusCode::CONFLICT,
+ Error::PreconditionFailed => StatusCode::PRECONDITION_FAILED,
Error::Forbidden(_) => StatusCode::FORBIDDEN,
Error::InternalError(
GarageError::Timeout
@@ -137,6 +142,7 @@ impl Error {
Error::NoSuchUpload => "NoSuchUpload",
Error::BucketAlreadyExists => "BucketAlreadyExists",
Error::BucketNotEmpty => "BucketNotEmpty",
+ Error::PreconditionFailed => "PreconditionFailed",
Error::Forbidden(_) => "AccessDenied",
Error::AuthorizationHeaderMalformed(_) => "AuthorizationHeaderMalformed",
Error::NotImplemented(_) => "NotImplemented",