1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | /* |
||
6 | * This file is part of the systemctl PHP library. |
||
7 | * |
||
8 | * (c) Martin Janser <[email protected]> |
||
9 | * |
||
10 | * This source file is subject to the GPL license that is bundled |
||
11 | * with this source code in the file LICENSE. |
||
12 | */ |
||
13 | |||
14 | namespace SystemCtl; |
||
15 | |||
16 | use Symfony\Component\Process\Process; |
||
17 | |||
18 | class CommandFailedException extends \RuntimeException |
||
19 | { |
||
20 | /** |
||
21 | * @var Process |
||
22 | */ |
||
23 | private $process; |
||
24 | |||
25 | /** |
||
26 | * @param Process $process |
||
27 | */ |
||
28 | 25 | public function __construct(Process $process) |
|
29 | { |
||
30 | 25 | $this->process = $process; |
|
31 | |||
32 | 25 | $message = sprintf( |
|
33 | 25 | 'Command "%s" failed with code %s, error returned: %s', |
|
34 | 25 | $this->process->getCommandLine(), |
|
35 | 25 | $this->process->getExitCode(), |
|
36 | 25 | $this->process->getErrorOutput() |
|
37 | ); |
||
38 | |||
39 | 25 | parent::__construct($message, $this->process->getExitCode()); |
|
40 | 25 | } |
|
41 | |||
42 | /** |
||
43 | * @return Process |
||
44 | */ |
||
45 | 5 | public function getProcess() |
|
46 | { |
||
47 | 5 | return $this->process; |
|
48 | } |
||
49 | } |
||
50 |