spaces.php

This commit is contained in:
Devang Srivastava 2017-12-07 21:23:18 +05:30
commit eefa32741e
845 changed files with 50409 additions and 0 deletions

View file

@ -0,0 +1,48 @@
<?php
namespace Aws\S3;
use Aws\Api\Parser\AbstractParser;
use Aws\Api\Parser\Exception\ParserException;
use Aws\CommandInterface;
use Aws\Exception\AwsException;
use Psr\Http\Message\ResponseInterface;
/**
* Converts malformed responses to a retryable error type.
*
* @internal
*/
class RetryableMalformedResponseParser extends AbstractParser
{
/** @var callable */
private $parser;
/** @var string */
private $exceptionClass;
public function __construct(
callable $parser,
$exceptionClass = AwsException::class
) {
$this->parser = $parser;
$this->exceptionClass = $exceptionClass;
}
public function __invoke(
CommandInterface $command,
ResponseInterface $response
) {
$fn = $this->parser;
try {
return $fn($command, $response);
} catch (ParserException $e) {
throw new $this->exceptionClass(
"Error parsing response for {$command->getName()}:"
. " AWS parsing error: {$e->getMessage()}",
$command,
['connection_error' => true, 'exception' => $e],
$e
);
}
}
}