pitrou commented on code in PR #14601:
URL: https://github.com/apache/arrow/pull/14601#discussion_r1025381713


##########
cpp/src/arrow/filesystem/s3_internal.h:
##########
@@ -76,6 +76,17 @@ inline bool IsConnectError(const 
Aws::Client::AWSError<Error>& error) {
   return false;
 }
 
+inline std::optional<std::string> BucketRegionFromError(
+    const Aws::Client::AWSError<Aws::S3::S3Errors>& error) {
+  const auto headers = error.GetResponseHeaders();

Review Comment:
   Nit
   ```suggestion
     const auto& headers = error.GetResponseHeaders();
   ```



##########
cpp/src/arrow/filesystem/s3_internal.h:
##########
@@ -158,8 +170,20 @@ Status ErrorToStatus(const std::string& prefix, const 
std::string& operation,
   if (error_type == Aws::S3::S3Errors::UNKNOWN) {
     ss << " (HTTP status " << static_cast<int>(error.GetResponseCode()) << ")";
   }
+
+  // Possibly an error due to wrong region configuration from client and 
bucket.
+  std::optional<std::string> wrong_region_msg = std::nullopt;
+  if (region.has_value()) {
+    const auto maybe_region = BucketRegionFromError(error);

Review Comment:
   Technically, this will only compile if `ErrorType` is `Aws::S3::S3Errors`. 
However, you could add a fallback for non-S3 errors:
   ```c++
   template <typename ErrorType>
   std::optional<std::string> BucketRegionFromError(const 
Aws::Client::AWSError<ErrorType>&) {
     return std::nullopt;
   }
   ```
   
   



-- 
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