Skip to content

Commit a342b2b

Browse files
committed
Debug - print previous exceptions
1 parent 2b850c5 commit a342b2b

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/Command/AnalyseCommand.php

+21-4
Original file line numberDiff line numberDiff line change
@@ -239,16 +239,33 @@ protected function execute(InputInterface $input, OutputInterface $output): int
239239
);
240240
} catch (Throwable $t) {
241241
if ($debug) {
242-
$inceptionResult->getStdOutput()->writeRaw(sprintf(
242+
$stdOutput = $inceptionResult->getStdOutput();
243+
$stdOutput->writeRaw(sprintf(
243244
'Uncaught %s: %s in %s:%d',
244245
get_class($t),
245246
$t->getMessage(),
246247
$t->getFile(),
247248
$t->getLine(),
248249
));
249-
$inceptionResult->getStdOutput()->writeLineFormatted('');
250-
$inceptionResult->getStdOutput()->writeRaw($t->getTraceAsString());
251-
$inceptionResult->getStdOutput()->writeLineFormatted('');
250+
$stdOutput->writeLineFormatted('');
251+
$stdOutput->writeRaw($t->getTraceAsString());
252+
$stdOutput->writeLineFormatted('');
253+
254+
$previous = $t->getPrevious();
255+
while ($previous !== null) {
256+
$stdOutput->writeLineFormatted('');
257+
$stdOutput->writeLineFormatted('Caused by:');
258+
$stdOutput->writeRaw(sprintf(
259+
'Uncaught %s: %s in %s:%d',
260+
get_class($previous),
261+
$previous->getMessage(),
262+
$previous->getFile(),
263+
$previous->getLine(),
264+
));
265+
$stdOutput->writeRaw($previous->getTraceAsString());
266+
$stdOutput->writeLineFormatted('');
267+
$previous = $previous->getPrevious();
268+
}
252269

253270
return $inceptionResult->handleReturn(1);
254271
}

0 commit comments

Comments
 (0)