BulkException.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Exception;
  7. use Magento\Framework\Phrase;
  8. /**
  9. * Exception thrown while processing bulk of entities
  10. *
  11. * @api
  12. * @since 101.0.7
  13. */
  14. class BulkException extends AbstractAggregateException
  15. {
  16. /**
  17. * @var array
  18. */
  19. private $data;
  20. /**
  21. * Exception thrown while processing bulk of entities
  22. *
  23. * It is capable of holding both successfully processed entities and failed entities.
  24. * Client can decide how to handle the information
  25. *
  26. * @param \Magento\Framework\Phrase $phrase
  27. * @param \Exception $cause
  28. * @param int $code
  29. */
  30. public function __construct(Phrase $phrase = null, \Exception $cause = null, $code = 0)
  31. {
  32. if ($phrase === null) {
  33. $phrase = new Phrase('One or more input exceptions have occurred while processing bulk.');
  34. }
  35. parent::__construct($phrase, $cause, $code);
  36. }
  37. /**
  38. * Add data
  39. *
  40. * @param array $data
  41. * @since 101.0.7
  42. */
  43. public function addData($data)
  44. {
  45. $this->data = $data;
  46. }
  47. /**
  48. * Retrieve data
  49. *
  50. * @return array
  51. * @since 101.0.7
  52. */
  53. public function getData()
  54. {
  55. return $this->data;
  56. }
  57. }