mirror of
https://github.com/SociallyDev/Spaces-API.git
synced 2025-08-20 05:13:42 -07:00
v2: Updates
* Simplifies & beautifies everything * Introduces a new Class system. * Errors are defaulted to AWS's handler. * New function names & more efficient handling. * Should fix a majority of the errors. Please read the README for more!
This commit is contained in:
parent
ad0726e41e
commit
e6d7753dc8
1095 changed files with 45088 additions and 2911 deletions
|
@ -2,9 +2,12 @@
|
|||
namespace Aws\S3;
|
||||
|
||||
use Aws\Api\Parser\AbstractParser;
|
||||
use Aws\Api\Parser\Exception\ParserException;
|
||||
use Aws\Api\StructureShape;
|
||||
use Aws\CommandInterface;
|
||||
use Aws\Exception\AwsException;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
/**
|
||||
* Converts errors returned with a status code of 200 to a retryable error type.
|
||||
|
@ -14,13 +17,12 @@ use Psr\Http\Message\ResponseInterface;
|
|||
class AmbiguousSuccessParser extends AbstractParser
|
||||
{
|
||||
private static $ambiguousSuccesses = [
|
||||
'UploadPart' => true,
|
||||
'UploadPartCopy' => true,
|
||||
'CopyObject' => true,
|
||||
'CompleteMultipartUpload' => true,
|
||||
];
|
||||
|
||||
/** @var callable */
|
||||
private $parser;
|
||||
/** @var callable */
|
||||
private $errorParser;
|
||||
/** @var string */
|
||||
|
@ -44,7 +46,16 @@ class AmbiguousSuccessParser extends AbstractParser
|
|||
&& isset(self::$ambiguousSuccesses[$command->getName()])
|
||||
) {
|
||||
$errorParser = $this->errorParser;
|
||||
$parsed = $errorParser($response);
|
||||
try {
|
||||
$parsed = $errorParser($response);
|
||||
} catch (ParserException $e) {
|
||||
$parsed = [
|
||||
'code' => 'ConnectionError',
|
||||
'message' => "An error connecting to the service occurred"
|
||||
. " while performing the " . $command->getName()
|
||||
. " operation."
|
||||
];
|
||||
}
|
||||
if (isset($parsed['code']) && isset($parsed['message'])) {
|
||||
throw new $this->exceptionClass(
|
||||
$parsed['message'],
|
||||
|
@ -57,4 +68,12 @@ class AmbiguousSuccessParser extends AbstractParser
|
|||
$fn = $this->parser;
|
||||
return $fn($command, $response);
|
||||
}
|
||||
|
||||
public function parseMemberFromStream(
|
||||
StreamInterface $stream,
|
||||
StructureShape $member,
|
||||
$response
|
||||
) {
|
||||
return $this->parser->parseMemberFromStream($stream, $member, $response);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue