This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
The following commit(s) were added to refs/heads/main by this push:
new f7616854 feat: Add PreconditionFailed Error so users can handle them
(#1993)
f7616854 is described below
commit f76168543ccc4e1e06d420f9ba8d5490ebb18fc1
Author: Xuanwo <[email protected]>
AuthorDate: Fri Apr 14 18:18:01 2023 +0800
feat: Add PreconditionFailed Error so users can handle them (#1993)
* feat: Add PreconditionFailed Error so users can handle them
Signed-off-by: Xuanwo <[email protected]>
* Fix typo
Signed-off-by: Xuanwo <[email protected]>
---------
Signed-off-by: Xuanwo <[email protected]>
---
core/src/services/azblob/error.rs | 1 +
core/src/services/azdfs/error.rs | 1 +
core/src/services/gcs/error.rs | 1 +
core/src/services/http/error.rs | 1 +
core/src/services/obs/error.rs | 1 +
core/src/services/oss/error.rs | 1 +
core/src/services/s3/error.rs | 1 +
core/src/types/error.rs | 6 ++++++
8 files changed, 13 insertions(+)
diff --git a/core/src/services/azblob/error.rs
b/core/src/services/azblob/error.rs
index 2ea489ac..9b52cc4f 100644
--- a/core/src/services/azblob/error.rs
+++ b/core/src/services/azblob/error.rs
@@ -90,6 +90,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>)
-> Result<Error> {
let (kind, retryable) = match parts.status {
StatusCode::NOT_FOUND => (ErrorKind::NotFound, false),
StatusCode::FORBIDDEN => (ErrorKind::PermissionDenied, false),
+ StatusCode::PRECONDITION_FAILED => (ErrorKind::PreconditionFailed,
false),
StatusCode::INTERNAL_SERVER_ERROR
| StatusCode::BAD_GATEWAY
| StatusCode::SERVICE_UNAVAILABLE
diff --git a/core/src/services/azdfs/error.rs b/core/src/services/azdfs/error.rs
index 44416cc5..3b6d2701 100644
--- a/core/src/services/azdfs/error.rs
+++ b/core/src/services/azdfs/error.rs
@@ -68,6 +68,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>)
-> Result<Error> {
let (kind, retryable) = match parts.status {
StatusCode::NOT_FOUND => (ErrorKind::NotFound, false),
StatusCode::FORBIDDEN => (ErrorKind::PermissionDenied, false),
+ StatusCode::PRECONDITION_FAILED => (ErrorKind::PreconditionFailed,
false),
StatusCode::INTERNAL_SERVER_ERROR
| StatusCode::BAD_GATEWAY
| StatusCode::SERVICE_UNAVAILABLE
diff --git a/core/src/services/gcs/error.rs b/core/src/services/gcs/error.rs
index b669e05f..efe19868 100644
--- a/core/src/services/gcs/error.rs
+++ b/core/src/services/gcs/error.rs
@@ -57,6 +57,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>)
-> Result<Error> {
let (kind, retryable) = match parts.status {
StatusCode::NOT_FOUND => (ErrorKind::NotFound, false),
StatusCode::FORBIDDEN => (ErrorKind::PermissionDenied, false),
+ StatusCode::PRECONDITION_FAILED => (ErrorKind::PreconditionFailed,
false),
StatusCode::INTERNAL_SERVER_ERROR
| StatusCode::BAD_GATEWAY
| StatusCode::SERVICE_UNAVAILABLE
diff --git a/core/src/services/http/error.rs b/core/src/services/http/error.rs
index 6fe6b57d..5794b8ae 100644
--- a/core/src/services/http/error.rs
+++ b/core/src/services/http/error.rs
@@ -31,6 +31,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>)
-> Result<Error> {
let (kind, retryable) = match parts.status {
StatusCode::NOT_FOUND => (ErrorKind::NotFound, false),
StatusCode::FORBIDDEN => (ErrorKind::PermissionDenied, false),
+ StatusCode::PRECONDITION_FAILED => (ErrorKind::PreconditionFailed,
false),
StatusCode::INTERNAL_SERVER_ERROR
| StatusCode::BAD_GATEWAY
| StatusCode::SERVICE_UNAVAILABLE
diff --git a/core/src/services/obs/error.rs b/core/src/services/obs/error.rs
index 0dab8632..7573157a 100644
--- a/core/src/services/obs/error.rs
+++ b/core/src/services/obs/error.rs
@@ -45,6 +45,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>)
-> Result<Error> {
let (kind, retryable) = match parts.status {
StatusCode::NOT_FOUND => (ErrorKind::NotFound, false),
StatusCode::FORBIDDEN => (ErrorKind::PermissionDenied, false),
+ StatusCode::PRECONDITION_FAILED => (ErrorKind::PreconditionFailed,
false),
StatusCode::INTERNAL_SERVER_ERROR
| StatusCode::BAD_GATEWAY
| StatusCode::SERVICE_UNAVAILABLE
diff --git a/core/src/services/oss/error.rs b/core/src/services/oss/error.rs
index f4cedbd0..a352af70 100644
--- a/core/src/services/oss/error.rs
+++ b/core/src/services/oss/error.rs
@@ -44,6 +44,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>)
-> Result<Error> {
let (kind, retryable) = match parts.status {
StatusCode::NOT_FOUND => (ErrorKind::NotFound, false),
StatusCode::FORBIDDEN => (ErrorKind::PermissionDenied, false),
+ StatusCode::PRECONDITION_FAILED => (ErrorKind::PreconditionFailed,
false),
StatusCode::INTERNAL_SERVER_ERROR
| StatusCode::BAD_GATEWAY
| StatusCode::SERVICE_UNAVAILABLE
diff --git a/core/src/services/s3/error.rs b/core/src/services/s3/error.rs
index 092a1010..89f8c522 100644
--- a/core/src/services/s3/error.rs
+++ b/core/src/services/s3/error.rs
@@ -44,6 +44,7 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>)
-> Result<Error> {
let (mut kind, mut retryable) = match parts.status {
StatusCode::NOT_FOUND => (ErrorKind::NotFound, false),
StatusCode::FORBIDDEN => (ErrorKind::PermissionDenied, false),
+ StatusCode::PRECONDITION_FAILED => (ErrorKind::PreconditionFailed,
false),
StatusCode::INTERNAL_SERVER_ERROR
| StatusCode::BAD_GATEWAY
| StatusCode::SERVICE_UNAVAILABLE
diff --git a/core/src/types/error.rs b/core/src/types/error.rs
index 84d08497..79475db9 100644
--- a/core/src/types/error.rs
+++ b/core/src/types/error.rs
@@ -70,6 +70,11 @@ pub enum ErrorKind {
RateLimited,
/// The given file paths are same.
IsSameFile,
+ /// The preconfition of this operation is not met.
+ ///
+ /// For example, reading a file with If-Match header but the file's ETag
+ /// is not match.
+ PreconditionFailed,
}
impl ErrorKind {
@@ -98,6 +103,7 @@ impl From<ErrorKind> for &'static str {
ErrorKind::AlreadyExists => "AlreadyExists",
ErrorKind::RateLimited => "RateLimited",
ErrorKind::IsSameFile => "IsSameFile",
+ ErrorKind::PreconditionFailed => "PreconditionFailed",
}
}
}