Total Complexity | 4 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Coverage | 87.5% |
Changes | 0 |
1 | <?php |
||
9 | class ProcessFailedException extends \RuntimeException implements ExceptionInterface |
||
10 | { |
||
11 | 2 | /** |
|
12 | * @var Process |
||
13 | */ |
||
14 | private $process; |
||
15 | |||
16 | public function __construct( |
||
17 | 2 | Process $process, |
|
18 | \Throwable $previous = null, |
||
19 | 2 | string $failureReason = "", |
|
20 | 2 | int $code = 0 |
|
21 | 2 | ) { |
|
22 | 2 | $this->process = $process; |
|
23 | 2 | ||
24 | 2 | $message = \Safe\sprintf( |
|
25 | 2 | 'Process with command "%s" has failed%s with exit code %d(%s)%s', |
|
26 | $process->getCommandLine(), |
||
27 | $process->isStarted() ? ' running' : '', |
||
28 | 2 | $process->getExitCode(), |
|
29 | 2 | $process->getExitCodeText(), |
|
30 | 2 | $failureReason ? ' because "' . $failureReason . '"' : '' |
|
31 | 2 | ); |
|
32 | |||
33 | 2 | parent::__construct( |
|
34 | $message, |
||
35 | $code, |
||
36 | $previous |
||
37 | ); |
||
38 | } |
||
39 | |||
40 | public function getProcess(): Process |
||
43 | } |
||
44 | } |
||
45 |