mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-02 01:10:53 +00:00
[Parallel] Display stack trace on --debug on parallel (#2561)
* [Parallel] Display stack trace on --debug on parallel * enhance * enhance * phpstan
This commit is contained in:
parent
38b6b60b24
commit
24d2250c59
|
@ -8,6 +8,7 @@ use Clue\React\NDJson\Decoder;
|
|||
use Clue\React\NDJson\Encoder;
|
||||
use PHPStan\Analyser\NodeScopeResolver;
|
||||
use Rector\Core\Application\FileProcessor\PhpFileProcessor;
|
||||
use Rector\Core\Console\Style\RectorConsoleOutputStyle;
|
||||
use Rector\Core\Provider\CurrentFileProvider;
|
||||
use Rector\Core\StaticReflection\DynamicSourceLocatorDecorator;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
|
@ -34,6 +35,7 @@ final class WorkerRunner
|
|||
private readonly PhpFileProcessor $phpFileProcessor,
|
||||
private readonly NodeScopeResolver $nodeScopeResolver,
|
||||
private readonly DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator,
|
||||
private readonly RectorConsoleOutputStyle $rectorConsoleOutputStyle
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -95,10 +97,7 @@ final class WorkerRunner
|
|||
);
|
||||
} catch (Throwable $throwable) {
|
||||
++$systemErrorsCount;
|
||||
|
||||
$errorMessage = sprintf('System error: "%s"', $throwable->getMessage()) . PHP_EOL;
|
||||
$errorMessage .= 'Run Rector with "--debug" option and post the report here: https://github.com/rectorphp/rector/issues/new';
|
||||
$systemErrors[] = new SystemError($errorMessage, $filePath, $throwable->getLine());
|
||||
$systemErrors = $this->collectSystemErrors($systemErrors, $throwable, $filePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,4 +117,27 @@ final class WorkerRunner
|
|||
|
||||
$decoder->on(ReactEvent::ERROR, $handleErrorCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SystemError[] $systemErrors
|
||||
* @return SystemError[]
|
||||
*/
|
||||
private function collectSystemErrors(array $systemErrors, Throwable $throwable, string $filePath): array
|
||||
{
|
||||
$errorMessage = sprintf('System error: "%s"', $throwable->getMessage()) . PHP_EOL;
|
||||
|
||||
if ($this->rectorConsoleOutputStyle->isDebug()) {
|
||||
$systemErrors[] = new SystemError(
|
||||
$errorMessage . PHP_EOL . 'Stack trace:' . PHP_EOL . $throwable->getTraceAsString(),
|
||||
$filePath,
|
||||
$throwable->getLine()
|
||||
);
|
||||
return $systemErrors;
|
||||
}
|
||||
|
||||
$errorMessage .= 'Run Rector with "--debug" option and post the report here: https://github.com/rectorphp/rector/issues/new';
|
||||
$systemErrors[] = new SystemError($errorMessage, $filePath, $throwable->getLine());
|
||||
|
||||
return $systemErrors;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user