Skip to content

Commit ab32ca9

Browse files
authored
Merge pull request #776 from enumag/patch-2
Fix exception loop in QueueConsumer
2 parents 499360e + 274aa0f commit ab32ca9

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

pkg/enqueue/Consumption/QueueConsumer.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ private function onEnd(ExtensionInterface $extension, int $startTime, ?int $exit
299299
}
300300

301301
/**
302-
* The logic is similar to one in Symfony's ExceptionListener::.
302+
* The logic is similar to one in Symfony's ExceptionListener::onKernelException().
303303
*
304304
* https://github.com/symfony/symfony/blob/cbe289517470eeea27162fd2d523eb29c95f775f/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php#L77
305305
*/
@@ -317,18 +317,16 @@ private function onProcessorException(ExtensionInterface $extension, Consumer $c
317317

318318
return $result;
319319
} catch (\Exception $e) {
320-
$wrapper = $e;
321-
while ($prev = $wrapper->getPrevious()) {
320+
$prev = $e;
321+
do {
322322
if ($exception === $wrapper = $prev) {
323323
throw $e;
324324
}
325-
}
325+
} while ($prev = $wrapper->getPrevious());
326326

327-
if ($exception !== $wrapper) {
328-
$prev = new \ReflectionProperty('Exception', 'previous');
329-
$prev->setAccessible(true);
330-
$prev->setValue($wrapper, $exception);
331-
}
327+
$prev = new \ReflectionProperty($wrapper instanceof \Exception ? \Exception::class : \Error::class, 'previous');
328+
$prev->setAccessible(true);
329+
$prev->setValue($wrapper, $exception);
332330

333331
throw $e;
334332
}

0 commit comments

Comments
 (0)