mirror of
https://github.com/SociallyDev/Spaces-API.git
synced 2025-08-19 21:03:44 -07:00
spaces.php
This commit is contained in:
parent
7755490b81
commit
eefa32741e
845 changed files with 50409 additions and 0 deletions
58
aws/Aws/Exception/MultipartUploadException.php
Normal file
58
aws/Aws/Exception/MultipartUploadException.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
namespace Aws\Exception;
|
||||
|
||||
use Aws\Multipart\UploadState;
|
||||
|
||||
class MultipartUploadException extends \RuntimeException
|
||||
{
|
||||
/** @var UploadState State of the erroneous transfer */
|
||||
private $state;
|
||||
|
||||
/**
|
||||
* @param UploadState $state Upload state at time of the exception.
|
||||
* @param \Exception|array $prev Exception being thrown.
|
||||
*/
|
||||
public function __construct(UploadState $state, $prev = null) {
|
||||
$msg = 'An exception occurred while performing a multipart upload';
|
||||
|
||||
if (is_array($prev)) {
|
||||
$msg = strtr($msg, ['performing' => 'uploading parts to']);
|
||||
$msg .= ". The following parts had errors:\n";
|
||||
/** @var $error AwsException */
|
||||
foreach ($prev as $part => $error) {
|
||||
$msg .= "- Part {$part}: " . $error->getMessage(). "\n";
|
||||
}
|
||||
} elseif ($prev instanceof AwsException) {
|
||||
switch ($prev->getCommand()->getName()) {
|
||||
case 'CreateMultipartUpload':
|
||||
case 'InitiateMultipartUpload':
|
||||
$action = 'initiating';
|
||||
break;
|
||||
case 'CompleteMultipartUpload':
|
||||
$action = 'completing';
|
||||
break;
|
||||
}
|
||||
if (isset($action)) {
|
||||
$msg = strtr($msg, ['performing' => $action]);
|
||||
}
|
||||
$msg .= ": {$prev->getMessage()}";
|
||||
}
|
||||
|
||||
if (!$prev instanceof \Exception) {
|
||||
$prev = null;
|
||||
}
|
||||
|
||||
parent::__construct($msg, 0, $prev);
|
||||
$this->state = $state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the state of the transfer
|
||||
*
|
||||
* @return UploadState
|
||||
*/
|
||||
public function getState()
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue