You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2023/04/14 09:49:50 UTC
[incubator-opendal] branch add-precondiftion-failed created (now ff964075)
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a change to branch add-precondiftion-failed
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
at ff964075 feat: Add PreconditionFailed Error so users can handle them
This branch includes the following new commits:
new ff964075 feat: Add PreconditionFailed Error so users can handle them
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[incubator-opendal] 01/01: feat: Add PreconditionFailed Error so users can handle them
Posted by xu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch add-precondiftion-failed
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
commit ff964075e47ab3b91e569a75ee2ef65cc53261c8
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Fri Apr 14 17:49:28 2023 +0800
feat: Add PreconditionFailed Error so users can handle them
Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
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..5f30fea7 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 exmaple, 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",
}
}
}