mirror of
https://github.com/SociallyDev/Spaces-API.git
synced 2025-08-14 02:27:23 -07:00
spaces.php
This commit is contained in:
parent
7755490b81
commit
eefa32741e
845 changed files with 50409 additions and 0 deletions
48
aws/Aws/S3/RetryableMalformedResponseParser.php
Normal file
48
aws/Aws/S3/RetryableMalformedResponseParser.php
Normal 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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue