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
|
@ -1,16 +1,28 @@
|
|||
<?php
|
||||
namespace Aws\Exception;
|
||||
|
||||
use Aws\Api\Shape;
|
||||
use Aws\CommandInterface;
|
||||
use Aws\HasDataTrait;
|
||||
use Aws\HasMonitoringEventsTrait;
|
||||
use Aws\MonitoringEventsInterface;
|
||||
use Aws\ResponseContainerInterface;
|
||||
use Aws\ResultInterface;
|
||||
use JmesPath\Env as JmesPath;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Aws\CommandInterface;
|
||||
use Aws\ResultInterface;
|
||||
|
||||
/**
|
||||
* Represents an AWS exception that is thrown when a command fails.
|
||||
*/
|
||||
class AwsException extends \RuntimeException
|
||||
class AwsException extends \RuntimeException implements
|
||||
MonitoringEventsInterface,
|
||||
ResponseContainerInterface,
|
||||
\ArrayAccess
|
||||
{
|
||||
use HasDataTrait;
|
||||
use HasMonitoringEventsTrait;
|
||||
|
||||
/** @var ResponseInterface */
|
||||
private $response;
|
||||
private $request;
|
||||
|
@ -19,9 +31,12 @@ class AwsException extends \RuntimeException
|
|||
private $requestId;
|
||||
private $errorType;
|
||||
private $errorCode;
|
||||
private $errorShape;
|
||||
private $connectionError;
|
||||
private $transferInfo;
|
||||
private $errorMessage;
|
||||
private $maxRetriesExceeded;
|
||||
|
||||
|
||||
/**
|
||||
* @param string $message Exception message
|
||||
|
@ -35,6 +50,7 @@ class AwsException extends \RuntimeException
|
|||
array $context = [],
|
||||
\Exception $previous = null
|
||||
) {
|
||||
$this->data = isset($context['body']) ? $context['body'] : [];
|
||||
$this->command = $command;
|
||||
$this->response = isset($context['response']) ? $context['response'] : null;
|
||||
$this->request = isset($context['request']) ? $context['request'] : null;
|
||||
|
@ -43,6 +59,7 @@ class AwsException extends \RuntimeException
|
|||
: null;
|
||||
$this->errorType = isset($context['type']) ? $context['type'] : null;
|
||||
$this->errorCode = isset($context['code']) ? $context['code'] : null;
|
||||
$this->errorShape = isset($context['error_shape']) ? $context['error_shape'] : null;
|
||||
$this->connectionError = !empty($context['connection_error']);
|
||||
$this->result = isset($context['result']) ? $context['result'] : null;
|
||||
$this->transferInfo = isset($context['transfer_stats'])
|
||||
|
@ -51,6 +68,8 @@ class AwsException extends \RuntimeException
|
|||
$this->errorMessage = isset($context['message'])
|
||||
? $context['message']
|
||||
: null;
|
||||
$this->monitoringEvents = [];
|
||||
$this->maxRetriesExceeded = false;
|
||||
parent::__construct($message, 0, $previous);
|
||||
}
|
||||
|
||||
|
@ -176,6 +195,16 @@ class AwsException extends \RuntimeException
|
|||
return $this->errorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the AWS error shape.
|
||||
*
|
||||
* @return Shape|null Returns null if no response was received
|
||||
*/
|
||||
public function getAwsErrorShape()
|
||||
{
|
||||
return $this->errorShape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all transfer information as an associative array if no $name
|
||||
* argument is supplied, or gets a specific transfer statistic if
|
||||
|
@ -205,4 +234,37 @@ class AwsException extends \RuntimeException
|
|||
{
|
||||
$this->transferInfo = $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the max number of retries is exceeded.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isMaxRetriesExceeded()
|
||||
{
|
||||
return $this->maxRetriesExceeded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the flag for max number of retries exceeded.
|
||||
*/
|
||||
public function setMaxRetriesExceeded()
|
||||
{
|
||||
$this->maxRetriesExceeded = true;
|
||||
}
|
||||
|
||||
public function hasKey($name)
|
||||
{
|
||||
return isset($this->data[$name]);
|
||||
}
|
||||
|
||||
public function get($key)
|
||||
{
|
||||
return $this[$key];
|
||||
}
|
||||
|
||||
public function search($expression)
|
||||
{
|
||||
return JmesPath::search($expression, $this->toArray());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue