Skip to content

Commit

Permalink
PHPStan Pro - report fatal errors more nicely
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jun 18, 2024
1 parent b88116b commit a99c71e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/Command/FixerApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
use PHPStan\Internal\DirectoryCreator;
use PHPStan\Internal\DirectoryCreatorException;
use PHPStan\PhpDoc\StubFilesProvider;
use PHPStan\Process\ProcessCanceledException;
use PHPStan\Process\ProcessCrashedException;
use PHPStan\Process\ProcessHelper;
use PHPStan\Process\ProcessPromise;
use PHPStan\ShouldNotHappenException;
Expand Down Expand Up @@ -479,12 +481,24 @@ private function analyse(
$this->processInProgress = null;
$server->close();
$output->writeln('<error>Worker process exited: ' . $e->getMessage() . '</error>');

if ($e instanceof ProcessCanceledException) {
return;
}

if ($e instanceof ProcessCrashedException) {
$message = 'Analysis crashed';
$trace = $e->getMessage();
} else {
$message = $e->getMessage();
$trace = $e->getTraceAsString();
}
$phpstanFixerEncoder->write(['action' => 'analysisCrash', 'data' => [
'internalErrors' => [new InternalError(
$e->getMessage(),
$message,
'running PHPStan Pro worker',
InternalError::prepareTrace($e),
$e->getTraceAsString(),
$trace,
false,
)],
]]);
Expand Down

0 comments on commit a99c71e

Please sign in to comment.