ExceptionInterface.php
1 year ago
InvalidArgumentException.php
1 year ago
LogicException.php
1 year ago
ProcessFailedException.php
1 year ago
ProcessSignaledException.php
1 year ago
ProcessTimedOutException.php
1 year ago
RuntimeException.php
1 year ago
ProcessFailedException.php
39 lines
| 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 | namespace Symfony\Component\Process\Exception; |
| 12 | |
| 13 | use Symfony\Component\Process\Process; |
| 14 | /** |
| 15 | * Exception for failed processes. |
| 16 | * |
| 17 | * @author Johannes M. Schmitt <schmittjoh@gmail.com> |
| 18 | */ |
| 19 | class ProcessFailedException extends \Symfony\Component\Process\Exception\RuntimeException |
| 20 | { |
| 21 | private $process; |
| 22 | public function __construct(Process $process) |
| 23 | { |
| 24 | if ($process->isSuccessful()) { |
| 25 | throw new \Symfony\Component\Process\Exception\InvalidArgumentException('Expected a failed process, but the given process was successful.'); |
| 26 | } |
| 27 | $error = sprintf('The command "%s" failed.' . "\n\nExit Code: %s(%s)\n\nWorking directory: %s", $process->getCommandLine(), $process->getExitCode(), $process->getExitCodeText(), $process->getWorkingDirectory()); |
| 28 | if (!$process->isOutputDisabled()) { |
| 29 | $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", $process->getOutput(), $process->getErrorOutput()); |
| 30 | } |
| 31 | parent::__construct($error); |
| 32 | $this->process = $process; |
| 33 | } |
| 34 | public function getProcess() |
| 35 | { |
| 36 | return $this->process; |
| 37 | } |
| 38 | } |
| 39 |