PluginProbe ʕ •ᴥ•ʔ
Transferito: WP Migration / trunk
Transferito: WP Migration vtrunk
trunk 11.4.0 12.0.0 13.1.0 14.0.0 14.0.11 14.0.7 14.1.0 14.1.1 14.1.2 14.1.3 14.1.4
transferito / vendor / aws / aws-sdk-php / src / S3 / Exception / DeleteMultipleObjectsException.php
transferito / vendor / aws / aws-sdk-php / src / S3 / Exception Last commit date
DeleteMultipleObjectsException.php 11 months ago PermanentRedirectException.php 11 months ago S3Exception.php 11 months ago S3MultipartUploadException.php 11 months ago
DeleteMultipleObjectsException.php
69 lines
1 <?php
2 namespace Aws\S3\Exception;
3
4 use Aws\HasMonitoringEventsTrait;
5 use Aws\MonitoringEventsInterface;
6
7 /**
8 * Exception thrown when errors occur while deleting objects using a
9 * {@see S3\BatchDelete} object.
10 */
11 class DeleteMultipleObjectsException extends \Exception implements
12 MonitoringEventsInterface
13 {
14 use HasMonitoringEventsTrait;
15
16 private $deleted = [];
17 private $errors = [];
18
19 /**
20 * @param array $deleted Array of successfully deleted keys
21 * @param array $errors Array of errors that were encountered
22 */
23 public function __construct(array $deleted, array $errors)
24 {
25 $this->deleted = array_values($deleted);
26 $this->errors = array_values($errors);
27 parent::__construct('Unable to delete certain keys when executing a'
28 . ' DeleteMultipleObjects request: '
29 . self::createMessageFromErrors($errors));
30 }
31
32 /**
33 * Create a single error message from multiple errors.
34 *
35 * @param array $errors Errors encountered
36 *
37 * @return string
38 */
39 public static function createMessageFromErrors(array $errors)
40 {
41 return "\n- " . implode("\n- ", array_map(function ($key) {
42 return json_encode($key);
43 }, $errors));
44 }
45
46 /**
47 * Get the errored objects
48 *
49 * @return array Returns an array of associative arrays, each containing
50 * a 'Code', 'Message', and 'Key' key.
51 */
52 public function getErrors()
53 {
54 return $this->errors;
55 }
56
57 /**
58 * Get the successfully deleted objects
59 *
60 * @return array Returns an array of associative arrays, each containing
61 * a 'Key' and optionally 'DeleteMarker' and
62 * 'DeleterMarkerVersionId'
63 */
64 public function getDeleted()
65 {
66 return $this->deleted;
67 }
68 }
69