ClSlaid commented on code in PR #2171:
URL: 
https://github.com/apache/incubator-opendal/pull/2171#discussion_r1181390728


##########
core/src/services/s3/error.rs:
##########
@@ -79,6 +71,34 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) 
-> Result<Error> {
     Ok(err)
 }
 
+/// Returns the Errorkind of this code and whether the error is retryable.
+/// All possible error code: 
<https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html#ErrorCodeList>
+pub fn parse_s3_error_code(code: &str) -> Option<(ErrorKind, bool)> {

Review Comment:
   Consider use `(ErrorKind, bool)` directly, instead of wrapping in `Option`.



##########
core/src/services/s3/error.rs:
##########
@@ -58,16 +58,8 @@ pub async fn parse_error(resp: Response<IncomingAsyncBody>) 
-> Result<Error> {
         .map(|s3_err| (format!("{s3_err:?}"), Some(s3_err)))
         .unwrap_or_else(|_| (String::from_utf8_lossy(&bs).into_owned(), None));
 
-    // All possible error code: 
<https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html#ErrorCodeList>
     if let Some(s3_err) = s3_err {
-        (kind, retryable) = match s3_err.code.as_str() {
-            // > Your socket connection to the server was not read from
-            // > or written to within the timeout period."
-            //
-            // It's Ok for us to retry it again.
-            "RequestTimeout" => (ErrorKind::Unexpected, true),
-            _ => (kind, retryable),
-        }
+        (kind, retryable) = 
parse_s3_error_code(s3_err.code.as_str()).unwrap_or((kind, retryable));

Review Comment:
   Looks like we will always need a `(ErrorKind, bool)` tuple here. Can we use 
`(ErrorKind, bool)` directly?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to