Skip to content

Commit

Permalink
Debug - print previous exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jul 15, 2022
1 parent 2b850c5 commit a342b2b
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/Command/AnalyseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,16 +239,33 @@ protected function execute(InputInterface $input, OutputInterface $output): int
);
} catch (Throwable $t) {
if ($debug) {
$inceptionResult->getStdOutput()->writeRaw(sprintf(
$stdOutput = $inceptionResult->getStdOutput();
$stdOutput->writeRaw(sprintf(
'Uncaught %s: %s in %s:%d',
get_class($t),
$t->getMessage(),
$t->getFile(),
$t->getLine(),
));
$inceptionResult->getStdOutput()->writeLineFormatted('');
$inceptionResult->getStdOutput()->writeRaw($t->getTraceAsString());
$inceptionResult->getStdOutput()->writeLineFormatted('');
$stdOutput->writeLineFormatted('');
$stdOutput->writeRaw($t->getTraceAsString());
$stdOutput->writeLineFormatted('');

$previous = $t->getPrevious();
while ($previous !== null) {
$stdOutput->writeLineFormatted('');
$stdOutput->writeLineFormatted('Caused by:');
$stdOutput->writeRaw(sprintf(
'Uncaught %s: %s in %s:%d',
get_class($previous),
$previous->getMessage(),
$previous->getFile(),
$previous->getLine(),
));
$stdOutput->writeRaw($previous->getTraceAsString());
$stdOutput->writeLineFormatted('');
$previous = $previous->getPrevious();
}

return $inceptionResult->handleReturn(1);
}
Expand Down

0 comments on commit a342b2b

Please sign in to comment.