diff --git a/core/lib/Drupal/Core/Queue/DelayedRequeueException.php b/core/lib/Drupal/Core/Queue/DelayedRequeueException.php index 2f402fedb5..93b6c82c35 100644 --- a/core/lib/Drupal/Core/Queue/DelayedRequeueException.php +++ b/core/lib/Drupal/Core/Queue/DelayedRequeueException.php @@ -29,12 +29,18 @@ class DelayedRequeueException extends \RuntimeException { * Constructs a DelayedRequeueException. * * @param int $delay - * The desired delay interval for this item. + * The desired delay interval for this item (in seconds). + * @param string $message + * The error message. + * @param int $code + * The error code. + * @param \Throwable|null $previous + * The previous throwable used for the exception chaining. */ - public function __construct(int $delay = 0) { - if ($delay > 0) { - $this->delay = $delay; - } + public function __construct(int $delay = 0, string $message = '', int $code = 0, \Throwable $previous = NULL) { + \assert($delay >= 0); + parent::__construct($message, $code, $previous); + $this->delay = $delay; } /** diff --git a/core/tests/Drupal/Tests/Core/Cron/CronExceptionsTest.php b/core/tests/Drupal/Tests/Core/Cron/CronExceptionsTest.php new file mode 100644 index 0000000000..871d9b8e60 --- /dev/null +++ b/core/tests/Drupal/Tests/Core/Cron/CronExceptionsTest.php @@ -0,0 +1,35 @@ +getDelay()); + static::assertSame('', $exception_without_parent->getMessage()); + static::assertSame(0, $exception_without_parent->getCode()); + static::assertNull($exception_without_parent->getPrevious()); + + $exception_with_parent = new DelayedRequeueException(100, 'Requeue', 200, new \Exception('The parent')); + static::assertSame(100, $exception_with_parent->getDelay()); + static::assertSame('Requeue', $exception_with_parent->getMessage()); + static::assertSame(200, $exception_with_parent->getCode()); + static::assertSame('The parent', $exception_with_parent->getPrevious()->getMessage()); + } + +}