update patch 1
This commit is contained in:
@@ -20,15 +20,14 @@ use Symfony\Component\Process\Process;
|
||||
*/
|
||||
class ProcessFailedException extends RuntimeException
|
||||
{
|
||||
private Process $process;
|
||||
|
||||
public function __construct(Process $process)
|
||||
{
|
||||
public function __construct(
|
||||
private Process $process,
|
||||
) {
|
||||
if ($process->isSuccessful()) {
|
||||
throw new InvalidArgumentException('Expected a failed process, but the given process was successful.');
|
||||
}
|
||||
|
||||
$error = sprintf('The command "%s" failed.'."\n\nExit Code: %s(%s)\n\nWorking directory: %s",
|
||||
$error = \sprintf('The command "%s" failed.'."\n\nExit Code: %s(%s)\n\nWorking directory: %s",
|
||||
$process->getCommandLine(),
|
||||
$process->getExitCode(),
|
||||
$process->getExitCodeText(),
|
||||
@@ -36,7 +35,7 @@ class ProcessFailedException extends RuntimeException
|
||||
);
|
||||
|
||||
if (!$process->isOutputDisabled()) {
|
||||
$error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s",
|
||||
$error .= \sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s",
|
||||
$process->getOutput(),
|
||||
$process->getErrorOutput()
|
||||
);
|
||||
|
||||
@@ -20,13 +20,10 @@ use Symfony\Component\Process\Process;
|
||||
*/
|
||||
final class ProcessSignaledException extends RuntimeException
|
||||
{
|
||||
private Process $process;
|
||||
|
||||
public function __construct(Process $process)
|
||||
{
|
||||
$this->process = $process;
|
||||
|
||||
parent::__construct(sprintf('The process has been signaled with signal "%s".', $process->getTermSignal()));
|
||||
public function __construct(
|
||||
private Process $process,
|
||||
) {
|
||||
parent::__construct(\sprintf('The process has been signaled with signal "%s".', $process->getTermSignal()));
|
||||
}
|
||||
|
||||
public function getProcess(): Process
|
||||
|
||||
@@ -18,15 +18,15 @@ use Symfony\Component\Process\Process;
|
||||
*/
|
||||
class ProcessStartFailedException extends ProcessFailedException
|
||||
{
|
||||
private Process $process;
|
||||
|
||||
public function __construct(Process $process, ?string $message)
|
||||
{
|
||||
public function __construct(
|
||||
private Process $process,
|
||||
?string $message,
|
||||
) {
|
||||
if ($process->isStarted()) {
|
||||
throw new InvalidArgumentException('Expected a process that failed during startup, but the given process was started successfully.');
|
||||
}
|
||||
|
||||
$error = sprintf('The command "%s" failed.'."\n\nWorking directory: %s\n\nError: %s",
|
||||
$error = \sprintf('The command "%s" failed.'."\n\nWorking directory: %s\n\nError: %s",
|
||||
$process->getCommandLine(),
|
||||
$process->getWorkingDirectory(),
|
||||
$message ?? 'unknown'
|
||||
@@ -34,8 +34,6 @@ class ProcessStartFailedException extends ProcessFailedException
|
||||
|
||||
// Skip parent constructor
|
||||
RuntimeException::__construct($error);
|
||||
|
||||
$this->process = $process;
|
||||
}
|
||||
|
||||
public function getProcess(): Process
|
||||
|
||||
@@ -23,15 +23,11 @@ class ProcessTimedOutException extends RuntimeException
|
||||
public const TYPE_GENERAL = 1;
|
||||
public const TYPE_IDLE = 2;
|
||||
|
||||
private Process $process;
|
||||
private int $timeoutType;
|
||||
|
||||
public function __construct(Process $process, int $timeoutType)
|
||||
{
|
||||
$this->process = $process;
|
||||
$this->timeoutType = $timeoutType;
|
||||
|
||||
parent::__construct(sprintf(
|
||||
public function __construct(
|
||||
private Process $process,
|
||||
private int $timeoutType,
|
||||
) {
|
||||
parent::__construct(\sprintf(
|
||||
'The process "%s" exceeded the timeout of %s seconds.',
|
||||
$process->getCommandLine(),
|
||||
$this->getExceededTimeout()
|
||||
@@ -58,7 +54,7 @@ class ProcessTimedOutException extends RuntimeException
|
||||
return match ($this->timeoutType) {
|
||||
self::TYPE_GENERAL => $this->process->getTimeout(),
|
||||
self::TYPE_IDLE => $this->process->getIdleTimeout(),
|
||||
default => throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType)),
|
||||
default => throw new \LogicException(\sprintf('Unknown timeout type "%d".', $this->timeoutType)),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user