PluginProbe
Media Cloud Sync / 1.3.11
Media Cloud Sync v1.3.11
1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 All 34 releases
media-cloud-sync / includes / sdk / s3 / Aws / Exception / MultipartUploadException.php

MultipartUploadException.php in Media Cloud Sync 1.3.11, at includes/sdk/s3/Aws/Exception/MultipartUploadException.php

58 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Dudlewebs\WPMCS\s3\Aws\Exception;
4
5 use Dudlewebs\WPMCS\s3\Aws\HasMonitoringEventsTrait;
6 use Dudlewebs\WPMCS\s3\Aws\MonitoringEventsInterface;
7 use Dudlewebs\WPMCS\s3\Aws\Multipart\UploadState;
8 class MultipartUploadException extends \RuntimeException implements MonitoringEventsInterface
9 {
10 use HasMonitoringEventsTrait;
11 /** @var UploadState State of the erroneous transfer */
12 private $state;
13 /**
14 * @param UploadState $state Upload state at time of the exception.
15 * @param \Exception|array $prev Exception being thrown.
16 */
17 public function __construct(UploadState $state, $prev = null)
18 {
19 $msg = 'An exception occurred while performing a multipart upload';
20 if (\is_array($prev)) {
21 $msg = \strtr($msg, ['performing' => 'uploading parts to']);
22 $msg .= ". The following parts had errors:\n";
23 /** @var $error AwsException */
24 foreach ($prev as $part => $error) {
25 $msg .= "- Part {$part}: " . $error->getMessage() . "\n";
26 }
27 } elseif ($prev instanceof AwsException) {
28 switch ($prev->getCommand()->getName()) {
29 case 'CreateMultipartUpload':
30 case 'InitiateMultipartUpload':
31 $action = 'initiating';
32 break;
33 case 'CompleteMultipartUpload':
34 $action = 'completing';
35 break;
36 }
37 if (isset($action)) {
38 $msg = \strtr($msg, ['performing' => $action]);
39 }
40 $msg .= ": {$prev->getMessage()}";
41 }
42 if (!$prev instanceof \Exception) {
43 $prev = null;
44 }
45 parent::__construct($msg, 0, $prev);
46 $this->state = $state;
47 }
48 /**
49 * Get the state of the transfer
50 *
51 * @return UploadState
52 */
53 public function getState()
54 {
55 return $this->state;
56 }
57 }
58