CronJobException.php 781 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Class CronJobException used to check that cron handles execution exception
  8. * Please see \Magento\Cron\Test\Unit\Model\ObserverTest
  9. */
  10. namespace Magento\Cron\Test\Unit\Model;
  11. class CronJobException
  12. {
  13. /**
  14. * @var \Throwable|null
  15. */
  16. private $exception;
  17. /**
  18. * @param \Throwable|null $exception
  19. */
  20. public function __construct(\Throwable $exception = null)
  21. {
  22. $this->exception = $exception;
  23. }
  24. /**
  25. * @throws \Throwable
  26. */
  27. public function execute()
  28. {
  29. if (!$this->exception) {
  30. $this->exception = new \Exception('Test exception');
  31. }
  32. throw $this->exception;
  33. }
  34. }