Debian Codegraph @

lib/3rdParty/composer/aws/aws-sdk-php/src/Exception/MultipartUploadException.php

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