mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-28 09:42:40 +01:00
Allow "PhutilAWSException" to identify "EBS: Not Found" errors
Summary: Ref T13630. Piledriver cares about EBS error specifics; expand this class a bit to expose more error information. Test Plan: Created and destroyed resource piles with Piledriver control code, elsewhere. Maniphest Tasks: T13630 Differential Revision: https://secure.phabricator.com/D21732
This commit is contained in:
parent
a028291f8e
commit
7cbdf37819
2 changed files with 43 additions and 3 deletions
|
@ -49,4 +49,24 @@ final class PhutilAWSException extends Exception {
|
||||||
return $this->httpStatus;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,6 +142,7 @@ abstract class PhutilAWSFuture extends FutureProxy {
|
||||||
try {
|
try {
|
||||||
$xml = @(new SimpleXMLElement($body));
|
$xml = @(new SimpleXMLElement($body));
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
|
phlog($ex);
|
||||||
$xml = null;
|
$xml = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,9 +156,28 @@ abstract class PhutilAWSFuture extends FutureProxy {
|
||||||
);
|
);
|
||||||
if ($xml) {
|
if ($xml) {
|
||||||
$params['RequestID'] = $xml->RequestID[0];
|
$params['RequestID'] = $xml->RequestID[0];
|
||||||
$errors = array($xml->Error);
|
|
||||||
foreach ($errors as $error) {
|
// NOTE: The S3 and EC2 APIs return slightly different error responses.
|
||||||
$params['Errors'][] = array($error->Code, $error->Message);
|
|
||||||
|
// 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),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue