Skip to content

Commit 280d421

Browse files
committed
small improvements
upd
1 parent 1673d72 commit 280d421

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/IO/S3/Client.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -705,12 +705,13 @@ Client::doRequest(RequestType & request, RequestFn request_fn) const
705705

706706
/// IllegalLocationConstraintException may indicate that we are working with an opt-in region (e.g. me-south-1)
707707
/// In that case, we need to update the region and try again
708-
if (error.GetResponseCode() != Aws::Http::HttpResponseCode::MOVED_PERMANENTLY && error.GetExceptionName() != "IllegalLocationConstraintException")
708+
bool is_illegal_constraint_exception = error.GetExceptionName() == "IllegalLocationConstraintException";
709+
if (error.GetResponseCode() != Aws::Http::HttpResponseCode::MOVED_PERMANENTLY && !is_illegal_constraint_exception)
709710
return result;
710711

711712
// maybe we detect a correct region
712713
bool new_region_detected = false;
713-
if (!detect_region || error.GetExceptionName() == "IllegalLocationConstraintException")
714+
if (!detect_region || is_illegal_constraint_exception)
714715
{
715716
if (auto region = GetErrorMarshaller()->ExtractRegion(error); !region.empty() && region != explicit_region)
716717
{
@@ -722,7 +723,7 @@ Client::doRequest(RequestType & request, RequestFn request_fn) const
722723
}
723724

724725
/// special handling for opt-in regions
725-
if (new_region_detected && error.GetExceptionName() == "IllegalLocationConstraintException" && initial_endpoint.substr(11) == "amazonaws.com")
726+
if (new_region_detected && is_illegal_constraint_exception && initial_endpoint.substr(11) == "amazonaws.com")
726727
{
727728
S3::URI new_uri(initial_endpoint);
728729
new_uri.addRegionToURI(request.getRegionOverride());

0 commit comments

Comments
 (0)