Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14840745
D21732.id51789.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D21732.id51789.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D21732: Allow "PhutilAWSException" to identify "EBS: Not Found" errors
Attached
Detach File
Event Timeline
Log In to Comment