MCPcopy Create free account
hub / github.com/apache/arrow / ErrorToStatus

Function ErrorToStatus

cpp/src/arrow/filesystem/s3_internal.h:169–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167// (e.g. "When completing multipart upload to bucket 'xxx', key 'xxx': ...")
168template <typename ErrorType>
169Status ErrorToStatus(const std::string& prefix, const std::string& operation,
170 const Aws::Client::AWSError<ErrorType>& error,
171 const std::optional<std::string>& region = std::nullopt) {
172 // XXX Handle fine-grained error types
173 // See
174 // https://sdk.amazonaws.com/cpp/api/LATEST/namespace_aws_1_1_s3.html#ae3f82f8132b619b6e91c88a9f1bde371
175 auto error_type = static_cast<Aws::S3::S3Errors>(error.GetErrorType());
176 std::stringstream ss;
177 ss << S3ErrorToString(error_type);
178 if (error_type == Aws::S3::S3Errors::UNKNOWN) {
179 ss << " (HTTP status " << static_cast<int>(error.GetResponseCode()) << ")";
180 }
181
182 // Possibly an error due to wrong region configuration from client and bucket.
183 std::optional<std::string> wrong_region_msg = std::nullopt;
184 if (region.has_value()) {
185 const auto maybe_region = BucketRegionFromError(error);
186 if (maybe_region.has_value() && maybe_region.value() != region.value()) {
187 wrong_region_msg = " Looks like the configured region is '" + region.value() +
188 "' while the bucket is located in '" + maybe_region.value() +
189 "'.";
190 }
191 }
192
193 auto request_id = error.GetRequestId();
194 auto request_str = request_id.empty() ? "" : (" (Request ID: " + request_id + ")");
195
196 return Status::IOError(prefix, "AWS Error ", ss.str(), " during ", operation,
197 " operation: ", error.GetMessage(), request_str,
198 wrong_region_msg.value_or(""));
199}
200
201template <typename ErrorType, typename... Args>
202Status ErrorToStatus(const std::tuple<Args&...>& prefix, const std::string& operation,

Callers 15

OutcomeToStatusFunction · 0.85
OutcomeToResultFunction · 0.85
InitMethod · 0.85
CreateMultipartUploadMethod · 0.85
AbortMethod · 0.85
UploadPartErrorMethod · 0.85
BucketExistsMethod · 0.85
CreateBucketMethod · 0.85
IsEmptyDirectoryMethod · 0.85

Calls 7

S3ErrorToStringFunction · 0.85
BucketRegionFromErrorFunction · 0.85
IOErrorFunction · 0.85
PrintTupleFunction · 0.85
strMethod · 0.80
valueMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected