diff --git a/Exception/DelayedMessageHandlingException.php b/Exception/DelayedMessageHandlingException.php index 3b81150b..10dc9fce 100644 --- a/Exception/DelayedMessageHandlingException.php +++ b/Exception/DelayedMessageHandlingException.php @@ -23,9 +23,10 @@ class DelayedMessageHandlingException extends RuntimeException implements Wrappe { use WrappedExceptionsTrait; - private Envelope $envelope; + private array $exceptions; + private ?Envelope $envelope; - public function __construct(array $exceptions, Envelope $envelope) + public function __construct(array $exceptions, Envelope $envelope = null) { $this->envelope = $envelope; @@ -55,7 +56,7 @@ public function getExceptions(): array return $this->exceptions; } - public function getEnvelope(): Envelope + public function getEnvelope(): ?Envelope { return $this->envelope; } diff --git a/Tests/Stamp/StringErrorCodeException.php b/Tests/Stamp/StringErrorCodeException.php deleted file mode 100644 index 63d6f88e..00000000 --- a/Tests/Stamp/StringErrorCodeException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Messenger\Tests\Stamp; - -class StringErrorCodeException extends \Exception -{ - public function __construct(string $message, string $code) - { - parent::__construct($message); - $this->code = $code; - } -} diff --git a/Worker.php b/Worker.php index 3dc85b52..eb0af634 100644 --- a/Worker.php +++ b/Worker.php @@ -189,7 +189,7 @@ private function ack(): bool $receiver->reject($envelope); } - if ($e instanceof HandlerFailedException || $e instanceof DelayedMessageHandlingException) { + if ($e instanceof HandlerFailedException || ($e instanceof DelayedMessageHandlingException && null !== $e->getEnvelope())) { $envelope = $e->getEnvelope(); }