From 792a5b16df01486e826e52274447c2d9f4232a7b Mon Sep 17 00:00:00 2001 From: Philipp Moritz Date: Thu, 1 Sep 2022 01:46:45 -0700 Subject: [PATCH 1/9] Show http status codes for S3 errors --- cpp/src/arrow/filesystem/s3_internal.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cpp/src/arrow/filesystem/s3_internal.h b/cpp/src/arrow/filesystem/s3_internal.h index 0943037aef0..a0e45ed8adc 100644 --- a/cpp/src/arrow/filesystem/s3_internal.h +++ b/cpp/src/arrow/filesystem/s3_internal.h @@ -154,8 +154,9 @@ Status ErrorToStatus(const std::string& prefix, const std::string& operation, // https://sdk.amazonaws.com/cpp/api/LATEST/namespace_aws_1_1_s3.html#ae3f82f8132b619b6e91c88a9f1bde371 return Status::IOError( prefix, "AWS Error ", - S3ErrorToString(static_cast(error.GetErrorType())), " during ", - operation, " operation: ", error.GetMessage()); + S3ErrorToString(static_cast(error.GetErrorType())), + " (http status code: ", static_cast(error.GetResponseCode()), ")", + " during ", operation, " operation: ", error.GetMessage()); } template From b93cebe1c1333fd254a66c8af7d58c4503ce7724 Mon Sep 17 00:00:00 2001 From: Philipp Moritz Date: Thu, 1 Sep 2022 01:58:49 -0700 Subject: [PATCH 2/9] Update s3_internal.h --- cpp/src/arrow/filesystem/s3_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/src/arrow/filesystem/s3_internal.h b/cpp/src/arrow/filesystem/s3_internal.h index a0e45ed8adc..77fdfa8cd5a 100644 --- a/cpp/src/arrow/filesystem/s3_internal.h +++ b/cpp/src/arrow/filesystem/s3_internal.h @@ -155,7 +155,7 @@ Status ErrorToStatus(const std::string& prefix, const std::string& operation, return Status::IOError( prefix, "AWS Error ", S3ErrorToString(static_cast(error.GetErrorType())), - " (http status code: ", static_cast(error.GetResponseCode()), ")", + " (http status ", static_cast(error.GetResponseCode()), ")", " during ", operation, " operation: ", error.GetMessage()); } From 2a664ca81c4c5fd4f7c2dcbe85feec9c7138c681 Mon Sep 17 00:00:00 2001 From: Philipp Moritz Date: Mon, 5 Sep 2022 11:12:21 -0700 Subject: [PATCH 3/9] update --- cpp/src/arrow/filesystem/s3_internal.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cpp/src/arrow/filesystem/s3_internal.h b/cpp/src/arrow/filesystem/s3_internal.h index 77fdfa8cd5a..e6c72e18548 100644 --- a/cpp/src/arrow/filesystem/s3_internal.h +++ b/cpp/src/arrow/filesystem/s3_internal.h @@ -152,10 +152,12 @@ Status ErrorToStatus(const std::string& prefix, const std::string& operation, // XXX Handle fine-grained error types // See // https://sdk.amazonaws.com/cpp/api/LATEST/namespace_aws_1_1_s3.html#ae3f82f8132b619b6e91c88a9f1bde371 + auto error = S3ErrorToString(static_cast(error.GetErrorType())); + if (error.GetErrorType() == Aws::S3::S3Errors::UNKNOWN) { + error += " (http status " + std::to_string(error.GetResponseCode()) + ")"; + } return Status::IOError( - prefix, "AWS Error ", - S3ErrorToString(static_cast(error.GetErrorType())), - " (http status ", static_cast(error.GetResponseCode()), ")", + prefix, "AWS Error ", error, " during ", operation, " operation: ", error.GetMessage()); } From 247f6cfe8a66dc832d13ed591102272327c71d9d Mon Sep 17 00:00:00 2001 From: Philipp Moritz Date: Mon, 5 Sep 2022 11:23:12 -0700 Subject: [PATCH 4/9] fix --- cpp/src/arrow/filesystem/s3_internal.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cpp/src/arrow/filesystem/s3_internal.h b/cpp/src/arrow/filesystem/s3_internal.h index e6c72e18548..3f7e6a09fe2 100644 --- a/cpp/src/arrow/filesystem/s3_internal.h +++ b/cpp/src/arrow/filesystem/s3_internal.h @@ -152,12 +152,12 @@ Status ErrorToStatus(const std::string& prefix, const std::string& operation, // XXX Handle fine-grained error types // See // https://sdk.amazonaws.com/cpp/api/LATEST/namespace_aws_1_1_s3.html#ae3f82f8132b619b6e91c88a9f1bde371 - auto error = S3ErrorToString(static_cast(error.GetErrorType())); + auto status = S3ErrorToString(static_cast(error.GetErrorType())); if (error.GetErrorType() == Aws::S3::S3Errors::UNKNOWN) { - error += " (http status " + std::to_string(error.GetResponseCode()) + ")"; + status += " (http status " + std::to_string(error.GetResponseCode()) + ")"; } return Status::IOError( - prefix, "AWS Error ", error, + prefix, "AWS Error ", status, " during ", operation, " operation: ", error.GetMessage()); } From fbce2310806a8ff975247aa9ce8a2db205bc3aed Mon Sep 17 00:00:00 2001 From: Philipp Moritz Date: Mon, 5 Sep 2022 11:40:57 -0700 Subject: [PATCH 5/9] fix --- cpp/src/arrow/filesystem/s3_internal.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cpp/src/arrow/filesystem/s3_internal.h b/cpp/src/arrow/filesystem/s3_internal.h index 3f7e6a09fe2..7b36873cb9d 100644 --- a/cpp/src/arrow/filesystem/s3_internal.h +++ b/cpp/src/arrow/filesystem/s3_internal.h @@ -152,8 +152,9 @@ Status ErrorToStatus(const std::string& prefix, const std::string& operation, // XXX Handle fine-grained error types // See // https://sdk.amazonaws.com/cpp/api/LATEST/namespace_aws_1_1_s3.html#ae3f82f8132b619b6e91c88a9f1bde371 - auto status = S3ErrorToString(static_cast(error.GetErrorType())); - if (error.GetErrorType() == Aws::S3::S3Errors::UNKNOWN) { + auto error_type = static_cast(error.GetErrorType()); + auto status = S3ErrorToString(error_type); + if (error_type == Aws::S3::S3Errors::UNKNOWN) { status += " (http status " + std::to_string(error.GetResponseCode()) + ")"; } return Status::IOError( From 4cd8d6d9d6b2f5b74279c63a510d1fa3c8c9b091 Mon Sep 17 00:00:00 2001 From: Philipp Moritz Date: Mon, 5 Sep 2022 12:01:13 -0700 Subject: [PATCH 6/9] fixes and lint --- cpp/src/arrow/filesystem/s3_internal.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cpp/src/arrow/filesystem/s3_internal.h b/cpp/src/arrow/filesystem/s3_internal.h index 7b36873cb9d..dc9d02df790 100644 --- a/cpp/src/arrow/filesystem/s3_internal.h +++ b/cpp/src/arrow/filesystem/s3_internal.h @@ -155,11 +155,10 @@ Status ErrorToStatus(const std::string& prefix, const std::string& operation, auto error_type = static_cast(error.GetErrorType()); auto status = S3ErrorToString(error_type); if (error_type == Aws::S3::S3Errors::UNKNOWN) { - status += " (http status " + std::to_string(error.GetResponseCode()) + ")"; + status += " (http status " + std::to_string(static_cast(error.GetResponseCode())) + ")"; } - return Status::IOError( - prefix, "AWS Error ", status, - " during ", operation, " operation: ", error.GetMessage()); + return Status::IOError(prefix, "AWS Error ", status, " during ", operation, + " operation: ", error.GetMessage()); } template From f2f93228e27275d05565822c076df5df9b984a34 Mon Sep 17 00:00:00 2001 From: Philipp Moritz Date: Mon, 5 Sep 2022 12:19:46 -0700 Subject: [PATCH 7/9] lint --- cpp/src/arrow/filesystem/s3_internal.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/src/arrow/filesystem/s3_internal.h b/cpp/src/arrow/filesystem/s3_internal.h index dc9d02df790..b333f6550a2 100644 --- a/cpp/src/arrow/filesystem/s3_internal.h +++ b/cpp/src/arrow/filesystem/s3_internal.h @@ -155,7 +155,8 @@ Status ErrorToStatus(const std::string& prefix, const std::string& operation, auto error_type = static_cast(error.GetErrorType()); auto status = S3ErrorToString(error_type); if (error_type == Aws::S3::S3Errors::UNKNOWN) { - status += " (http status " + std::to_string(static_cast(error.GetResponseCode())) + ")"; + status += " (http status " + + std::to_string(static_cast(error.GetResponseCode())) + ")"; } return Status::IOError(prefix, "AWS Error ", status, " during ", operation, " operation: ", error.GetMessage()); From 4b3837defc8c67fb45d3ca5dbb8aca624d4c9b88 Mon Sep 17 00:00:00 2001 From: Philipp Moritz Date: Mon, 5 Sep 2022 14:49:08 -0700 Subject: [PATCH 8/9] use stringstream --- cpp/src/arrow/filesystem/s3_internal.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cpp/src/arrow/filesystem/s3_internal.h b/cpp/src/arrow/filesystem/s3_internal.h index b333f6550a2..8f905489499 100644 --- a/cpp/src/arrow/filesystem/s3_internal.h +++ b/cpp/src/arrow/filesystem/s3_internal.h @@ -153,12 +153,12 @@ Status ErrorToStatus(const std::string& prefix, const std::string& operation, // See // https://sdk.amazonaws.com/cpp/api/LATEST/namespace_aws_1_1_s3.html#ae3f82f8132b619b6e91c88a9f1bde371 auto error_type = static_cast(error.GetErrorType()); - auto status = S3ErrorToString(error_type); + std::stringstream ss; + ss << S3ErrorToString(error_type); if (error_type == Aws::S3::S3Errors::UNKNOWN) { - status += " (http status " + - std::to_string(static_cast(error.GetResponseCode())) + ")"; + ss << " (http status " << static_cast(error.GetResponseCode()) << ")"; } - return Status::IOError(prefix, "AWS Error ", status, " during ", operation, + return Status::IOError(prefix, "AWS Error ", ss.str(), " during ", operation, " operation: ", error.GetMessage()); } From 5d2c2e622739df7b7a4461aa5aa0e8b546719a33 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Tue, 6 Sep 2022 15:44:32 +0200 Subject: [PATCH 9/9] Capitalize HTTP --- cpp/src/arrow/filesystem/s3_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/src/arrow/filesystem/s3_internal.h b/cpp/src/arrow/filesystem/s3_internal.h index 8f905489499..f154d6c4981 100644 --- a/cpp/src/arrow/filesystem/s3_internal.h +++ b/cpp/src/arrow/filesystem/s3_internal.h @@ -156,7 +156,7 @@ Status ErrorToStatus(const std::string& prefix, const std::string& operation, std::stringstream ss; ss << S3ErrorToString(error_type); if (error_type == Aws::S3::S3Errors::UNKNOWN) { - ss << " (http status " << static_cast(error.GetResponseCode()) << ")"; + ss << " (HTTP status " << static_cast(error.GetResponseCode()) << ")"; } return Status::IOError(prefix, "AWS Error ", ss.str(), " during ", operation, " operation: ", error.GetMessage());