Page MenuHomePhabricator

D21732.id51789.diff
No OneTemporary

D21732.id51789.diff

diff --git a/src/future/aws/PhutilAWSException.php b/src/future/aws/PhutilAWSException.php
--- a/src/future/aws/PhutilAWSException.php
+++ b/src/future/aws/PhutilAWSException.php
@@ -49,4 +49,24 @@
return $this->httpStatus;
}
+ public function isNotFoundError() {
+ if ($this->hasErrorCode('InvalidVolume.NotFound')) {
+ return true;
+ }
+
+ return false;
+ }
+
+ private function hasErrorCode($code) {
+ $errors = idx($this->params, 'Errors', array());
+
+ foreach ($errors as $error) {
+ if ($error[0] === $code) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
}
diff --git a/src/future/aws/PhutilAWSFuture.php b/src/future/aws/PhutilAWSFuture.php
--- a/src/future/aws/PhutilAWSFuture.php
+++ b/src/future/aws/PhutilAWSFuture.php
@@ -142,6 +142,7 @@
try {
$xml = @(new SimpleXMLElement($body));
} catch (Exception $ex) {
+ phlog($ex);
$xml = null;
}
@@ -155,9 +156,28 @@
);
if ($xml) {
$params['RequestID'] = $xml->RequestID[0];
- $errors = array($xml->Error);
- foreach ($errors as $error) {
- $params['Errors'][] = array($error->Code, $error->Message);
+
+ // NOTE: The S3 and EC2 APIs return slightly different error responses.
+
+ // In S3 responses, there's a simple top-level "<Error>" element.
+ $s3_error = $xml->Error;
+ if ($s3_error) {
+ $params['Errors'][] = array(
+ phutil_string_cast($s3_error->Code),
+ phutil_string_cast($s3_error->Message),
+ );
+ }
+
+ // In EC2 responses, there's an "<Errors>" element with "<Error>"
+ // children.
+ $ec2_errors = $xml->Errors[0];
+ if ($ec2_errors) {
+ foreach ($ec2_errors as $error) {
+ $params['Errors'][] = array(
+ phutil_string_cast($error->Code),
+ phutil_string_cast($error->Message),
+ );
+ }
}
}

File Metadata

Mime Type
text/plain
Expires
Sun, Feb 2, 9:00 AM (57 m, 58 s)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7084108
Default Alt Text
D21732.id51789.diff (1 KB)

Event Timeline