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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
<?php
|
||||
namespace Aws\Exception;
|
||||
|
||||
class CouldNotCreateChecksumException extends \RuntimeException
|
||||
use Aws\HasMonitoringEventsTrait;
|
||||
use Aws\MonitoringEventsInterface;
|
||||
|
||||
class CouldNotCreateChecksumException extends \RuntimeException implements
|
||||
MonitoringEventsInterface
|
||||
{
|
||||
use HasMonitoringEventsTrait;
|
||||
|
||||
public function __construct($algorithm, \Exception $previous = null)
|
||||
{
|
||||
$prefix = $algorithm === 'md5' ? "An" : "A";
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
<?php
|
||||
namespace Aws\Exception;
|
||||
|
||||
class CredentialsException extends \RuntimeException {}
|
||||
use Aws\HasMonitoringEventsTrait;
|
||||
use Aws\MonitoringEventsInterface;
|
||||
|
||||
class CredentialsException extends \RuntimeException implements
|
||||
MonitoringEventsInterface
|
||||
{
|
||||
use HasMonitoringEventsTrait;
|
||||
}
|
||||
|
|
11
aws/Aws/Exception/CryptoException.php
Normal file
11
aws/Aws/Exception/CryptoException.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace Aws\Exception;
|
||||
|
||||
/**
|
||||
* This class represents exceptions related to logic surrounding client-side
|
||||
* encryption usage.
|
||||
*/
|
||||
class CryptoException extends \RuntimeException
|
||||
{
|
||||
|
||||
}
|
11
aws/Aws/Exception/CryptoPolyfillException.php
Normal file
11
aws/Aws/Exception/CryptoPolyfillException.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace Aws\Exception;
|
||||
|
||||
/**
|
||||
* Class CryptoPolyfillException
|
||||
* @package Aws\Exception
|
||||
*/
|
||||
class CryptoPolyfillException extends \RuntimeException
|
||||
{
|
||||
|
||||
}
|
38
aws/Aws/Exception/EventStreamDataException.php
Normal file
38
aws/Aws/Exception/EventStreamDataException.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
namespace Aws\Exception;
|
||||
|
||||
/**
|
||||
* Represents an exception that was supplied via an EventStream.
|
||||
*/
|
||||
class EventStreamDataException extends \RuntimeException
|
||||
{
|
||||
private $errorCode;
|
||||
private $errorMessage;
|
||||
|
||||
public function __construct($code, $message)
|
||||
{
|
||||
$this->errorCode = $code;
|
||||
$this->errorMessage = $message;
|
||||
parent::__construct($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the AWS error code.
|
||||
*
|
||||
* @return string|null Returns null if no response was received
|
||||
*/
|
||||
public function getAwsErrorCode()
|
||||
{
|
||||
return $this->errorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the concise error message if any.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAwsErrorMessage()
|
||||
{
|
||||
return $this->errorMessage;
|
||||
}
|
||||
}
|
11
aws/Aws/Exception/IncalculablePayloadException.php
Normal file
11
aws/Aws/Exception/IncalculablePayloadException.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace Aws\Exception;
|
||||
|
||||
use Aws\HasMonitoringEventsTrait;
|
||||
use Aws\MonitoringEventsInterface;
|
||||
|
||||
class IncalculablePayloadException extends \RuntimeException implements
|
||||
MonitoringEventsInterface
|
||||
{
|
||||
use HasMonitoringEventsTrait;
|
||||
}
|
11
aws/Aws/Exception/InvalidJsonException.php
Normal file
11
aws/Aws/Exception/InvalidJsonException.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace Aws\Exception;
|
||||
|
||||
use Aws\HasMonitoringEventsTrait;
|
||||
use Aws\MonitoringEventsInterface;
|
||||
|
||||
class InvalidJsonException extends \RuntimeException implements
|
||||
MonitoringEventsInterface
|
||||
{
|
||||
use HasMonitoringEventsTrait;
|
||||
}
|
11
aws/Aws/Exception/InvalidRegionException.php
Normal file
11
aws/Aws/Exception/InvalidRegionException.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
namespace Aws\Exception;
|
||||
|
||||
use Aws\HasMonitoringEventsTrait;
|
||||
use Aws\MonitoringEventsInterface;
|
||||
|
||||
class InvalidRegionException extends \RuntimeException implements
|
||||
MonitoringEventsInterface
|
||||
{
|
||||
use HasMonitoringEventsTrait;
|
||||
}
|
|
@ -1,10 +1,15 @@
|
|||
<?php
|
||||
namespace Aws\Exception;
|
||||
|
||||
use Aws\HasMonitoringEventsTrait;
|
||||
use Aws\MonitoringEventsInterface;
|
||||
use Aws\Multipart\UploadState;
|
||||
|
||||
class MultipartUploadException extends \RuntimeException
|
||||
class MultipartUploadException extends \RuntimeException implements
|
||||
MonitoringEventsInterface
|
||||
{
|
||||
use HasMonitoringEventsTrait;
|
||||
|
||||
/** @var UploadState State of the erroneous transfer */
|
||||
private $state;
|
||||
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
<?php
|
||||
namespace Aws\Exception;
|
||||
|
||||
class UnresolvedApiException extends \RuntimeException {}
|
||||
use Aws\HasMonitoringEventsTrait;
|
||||
use Aws\MonitoringEventsInterface;
|
||||
|
||||
class UnresolvedApiException extends \RuntimeException implements
|
||||
MonitoringEventsInterface
|
||||
{
|
||||
use HasMonitoringEventsTrait;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
<?php
|
||||
namespace Aws\Exception;
|
||||
|
||||
class UnresolvedEndpointException extends \RuntimeException {}
|
||||
use Aws\HasMonitoringEventsTrait;
|
||||
use Aws\MonitoringEventsInterface;
|
||||
|
||||
class UnresolvedEndpointException extends \RuntimeException implements
|
||||
MonitoringEventsInterface
|
||||
{
|
||||
use HasMonitoringEventsTrait;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
<?php
|
||||
namespace Aws\Exception;
|
||||
|
||||
class UnresolvedSignatureException extends \RuntimeException {}
|
||||
use Aws\HasMonitoringEventsTrait;
|
||||
use Aws\MonitoringEventsInterface;
|
||||
|
||||
class UnresolvedSignatureException extends \RuntimeException implements
|
||||
MonitoringEventsInterface
|
||||
{
|
||||
use HasMonitoringEventsTrait;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue