Skip to content

Commit d10414d

Browse files
authored
Merge pull request php-enqueue#1114 from macghriogair/bugfix/queue-consume-catch-throwable
[fix] queue consumption: catch throwable for processing errors
2 parents f0437db + 0375baa commit d10414d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

pkg/enqueue/Consumption/Context/ProcessorException.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class ProcessorException
2626
private $message;
2727

2828
/**
29-
* @var \Exception
29+
* @var \Throwable
3030
*/
3131
private $exception;
3232

@@ -44,7 +44,7 @@ final class ProcessorException
4444
*/
4545
private $logger;
4646

47-
public function __construct(Context $context, Consumer $consumer, Message $message, \Exception $exception, int $receivedAt, LoggerInterface $logger)
47+
public function __construct(Context $context, Consumer $consumer, Message $message, \Throwable $exception, int $receivedAt, LoggerInterface $logger)
4848
{
4949
$this->context = $context;
5050
$this->consumer = $consumer;
@@ -69,7 +69,7 @@ public function getMessage(): Message
6969
return $this->message;
7070
}
7171

72-
public function getException(): \Exception
72+
public function getException(): \Throwable
7373
{
7474
return $this->exception;
7575
}

pkg/enqueue/Consumption/QueueConsumer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public function consume(ExtensionInterface $runtimeExtension = null): void
195195
if (null === $result) {
196196
try {
197197
$result = $processor->process($message, $this->interopContext);
198-
} catch (\Exception $e) {
198+
} catch (\Exception | \Throwable $e) {
199199
$result = $this->onProcessorException($extension, $consumer, $message, $e, $receivedAt);
200200
}
201201
}
@@ -303,7 +303,7 @@ private function onEnd(ExtensionInterface $extension, int $startTime, ?int $exit
303303
*
304304
* https://github.com/symfony/symfony/blob/cbe289517470eeea27162fd2d523eb29c95f775f/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php#L77
305305
*/
306-
private function onProcessorException(ExtensionInterface $extension, Consumer $consumer, Message $message, \Exception $exception, int $receivedAt)
306+
private function onProcessorException(ExtensionInterface $extension, Consumer $consumer, Message $message, \Throwable $exception, int $receivedAt)
307307
{
308308
$processorException = new ProcessorException($this->interopContext, $consumer, $message, $exception, $receivedAt, $this->logger);
309309

0 commit comments

Comments
 (0)