| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
* This file is part of the Symfony package. |
| 5 |
* |
| 6 |
* (c) Fabien Potencier <fabien@symfony.com> |
| 7 |
* |
| 8 |
* For the full copyright and license information, please view the LICENSE |
| 9 |
* file that was distributed with this source code. |
| 10 |
*/ |
| 11 |
|
| 12 |
/** |
| 13 |
* Exception for failed processes. |
| 14 |
* |
| 15 |
* @author Johannes M. Schmitt <schmittjoh@gmail.com> |
| 16 |
*/ |
| 17 |
class Symfony_Process_Exception_ProcessFailedException extends Symfony_Process_Exception_RuntimeException |
| 18 |
{ |
| 19 |
private $process; |
| 20 |
|
| 21 |
public function __construct(Symfony_Process_Process $process) |
| 22 |
{ |
| 23 |
if ($process->isSuccessful()) { |
| 24 |
throw new Symfony_Process_Exception_InvalidArgumentException('Expected a failed process, but the given process was successful.'); |
| 25 |
} |
| 26 |
|
| 27 |
$error = sprintf('The command "%s" failed.'."\nExit Code: %s(%s)", |
| 28 |
$process->getCommandLine(), |
| 29 |
$process->getExitCode(), |
| 30 |
$process->getExitCodeText() |
| 31 |
); |
| 32 |
|
| 33 |
if (!$process->isOutputDisabled()) { |
| 34 |
$error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", |
| 35 |
$process->getOutput(), |
| 36 |
$process->getErrorOutput() |
| 37 |
); |
| 38 |
} |
| 39 |
|
| 40 |
parent::__construct($error); |
| 41 |
|
| 42 |
$this->process = $process; |
| 43 |
} |
| 44 |
|
| 45 |
public function getProcess() |
| 46 |
{ |
| 47 |
return $this->process; |
| 48 |
} |
| 49 |
} |
| 50 |
|