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 b9758653 fix(services/supabase): correctly set retryable (#2295)
b9758653 is described below
commit b975865362d5cc14e769b362a90044a3f5d3b9d7
Author: xyJi <[email protected]>
AuthorDate: Tue May 23 16:41:30 2023 +0800
fix(services/supabase): correctly set retryable (#2295)
* This PR parse the supabase statuscode more detailed and set the
retryability correctly.
Signed-off-by: Ji-Xinyou <[email protected]>
---
core/src/services/supabase/error.rs | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/core/src/services/supabase/error.rs
b/core/src/services/supabase/error.rs
index 1acab706..f9eb0b6e 100644
--- a/core/src/services/supabase/error.rs
+++ b/core/src/services/supabase/error.rs
@@ -59,15 +59,18 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>)
-> Result<Error> {
// Return the error kind and whether it is retryable
fn parse_supabase_error(err: &SupabaseError) -> (ErrorKind, bool) {
let code = err.status_code.parse::<u16>().unwrap();
- if code == StatusCode::CONFLICT.as_u16() && err.error == "Duplicate" {
- (ErrorKind::AlreadyExists, false)
- } else if code == StatusCode::NOT_FOUND.as_u16() {
- (ErrorKind::NotFound, false)
- } else if code == StatusCode::FORBIDDEN.as_u16() {
- (ErrorKind::PermissionDenied, false)
- } else if code == StatusCode::PRECONDITION_FAILED.as_u16() {
- (ErrorKind::ConditionNotMatch, false)
- } else {
- (ErrorKind::Unexpected, false)
+ let status_code = StatusCode::from_u16(code).unwrap();
+ match status_code {
+ StatusCode::CONFLICT => (ErrorKind::AlreadyExists, false),
+ StatusCode::NOT_FOUND => (ErrorKind::NotFound, false),
+ StatusCode::FORBIDDEN => (ErrorKind::PermissionDenied, false),
+ StatusCode::PRECONDITION_FAILED | StatusCode::NOT_MODIFIED => {
+ (ErrorKind::ConditionNotMatch, false)
+ }
+ StatusCode::INTERNAL_SERVER_ERROR
+ | StatusCode::BAD_GATEWAY
+ | StatusCode::SERVICE_UNAVAILABLE
+ | StatusCode::GATEWAY_TIMEOUT => (ErrorKind::Unexpected, true),
+ _ => (ErrorKind::Unexpected, false),
}
}