|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* See class comment |
|
4
|
|
|
* |
|
5
|
|
|
* PHP Version 5 |
|
6
|
|
|
* |
|
7
|
|
|
* @category Netresearch |
|
8
|
|
|
* @package Netresearch\Kite\Exception |
|
9
|
|
|
* @author Christian Opitz <[email protected]> |
|
10
|
|
|
* @license http://www.netresearch.de Netresearch Copyright |
|
11
|
|
|
* @link http://www.netresearch.de |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Netresearch\Kite\Exception; |
|
15
|
|
|
use Netresearch\Kite\Exception; |
|
16
|
|
|
use Netresearch\Kite\Service\Process; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Class ProcessFailedException |
|
20
|
|
|
* |
|
21
|
|
|
* @category Netresearch |
|
22
|
|
|
* @package Netresearch\Kite\Exception |
|
23
|
|
|
* @author Christian Opitz <[email protected]> |
|
24
|
|
|
* @license http://www.netresearch.de Netresearch Copyright |
|
25
|
|
|
* @link http://www.netresearch.de |
|
26
|
|
|
*/ |
|
27
|
|
|
class ProcessFailedException extends Exception |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* @var Process |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $process; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* ProcessFailedException constructor. |
|
36
|
|
|
* |
|
37
|
|
|
* @param Process $process The process |
|
38
|
|
|
*/ |
|
39
|
|
|
public function __construct(Process $process) |
|
40
|
|
|
{ |
|
41
|
|
|
if ($process->isSuccessful()) { |
|
42
|
|
|
throw new Exception('Expected a failed process, but the given process was successful.'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
$error = sprintf( |
|
46
|
|
|
'The command "%s" failed.'."\n\nExit Code: %s(%s)\n\nWorking directory: %s", |
|
47
|
|
|
$process->getCommandLine(), |
|
48
|
|
|
$process->getExitCode(), |
|
49
|
|
|
$process->getExitCodeText(), |
|
50
|
|
|
$process->getWorkingDirectory() |
|
51
|
|
|
); |
|
52
|
|
|
|
|
53
|
|
|
if (!$process->isOutputDisabled()) { |
|
54
|
|
|
$error .= sprintf( |
|
55
|
|
|
"\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", |
|
56
|
|
|
$process->getOutput(), |
|
57
|
|
|
$process->getErrorOutput() |
|
58
|
|
|
); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
parent::__construct($error); |
|
62
|
|
|
|
|
63
|
|
|
$this->process = $process; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Get the process |
|
68
|
|
|
* |
|
69
|
|
|
* @return Process |
|
70
|
|
|
*/ |
|
71
|
|
|
public function getProcess() |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->process; |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
?> |
|
78
|
|
|
|