Skip to content

Commit 8878877

Browse files
authored
Fix exception loop in QueueConsumer
1 parent 499360e commit 8878877

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

pkg/enqueue/Consumption/QueueConsumer.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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)