1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/* (c) Anton Medvedev <[email protected]> |
3
|
|
|
* |
4
|
|
|
* For the full copyright and license information, please view the LICENSE |
5
|
|
|
* file that was distributed with this source code. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Deployer\Exception; |
9
|
|
|
|
10
|
|
|
use Symfony\Component\Process\Process; |
11
|
|
|
|
12
|
|
|
class RunException extends Exception |
13
|
|
|
{ |
14
|
|
|
private $filename; |
15
|
|
|
private $lineNumber; |
16
|
|
|
private $hostname; |
17
|
|
|
private $command; |
18
|
|
|
private $exitCode; |
19
|
|
|
private $output; |
20
|
|
|
private $errorOutput; |
21
|
|
|
|
22
|
|
|
public function __construct( |
23
|
|
|
string $filename, |
24
|
|
|
int $lineNumber, |
25
|
|
|
string $hostname, |
26
|
|
|
string $command, |
27
|
|
|
int $exitCode, |
28
|
|
|
string $output, |
29
|
|
|
string $errorOutput |
30
|
|
|
) { |
31
|
|
|
$this->filename = $filename; |
32
|
|
|
$this->lineNumber = $lineNumber; |
33
|
|
|
$this->hostname = $hostname; |
34
|
|
|
$this->command = $command; |
35
|
|
|
$this->exitCode = $exitCode; |
36
|
|
|
$this->output = $output; |
37
|
|
|
$this->errorOutput = $errorOutput; |
38
|
|
|
|
39
|
|
|
$message = sprintf('The command "%s" failed.', $command); |
40
|
|
|
parent::__construct($message, $exitCode); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function getFilename() |
44
|
|
|
{ |
45
|
|
|
return $this->filename; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function getLineNumber() |
49
|
|
|
{ |
50
|
|
|
return $this->lineNumber; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function getHostname(): string |
54
|
|
|
{ |
55
|
|
|
return $this->hostname; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function getCommand(): string |
59
|
|
|
{ |
60
|
|
|
return $this->command; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function getExitCode(): int |
64
|
|
|
{ |
65
|
|
|
return $this->exitCode; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function getExitCodeText(): string |
69
|
|
|
{ |
70
|
|
|
return Process::$exitCodes[$this->exitCode] ?? 'Unknown error'; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function getOutput(): string |
74
|
|
|
{ |
75
|
|
|
return $this->output; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function getErrorOutput(): string |
79
|
|
|
{ |
80
|
|
|
return $this->errorOutput; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|