Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\Process\Exception; Chris@0: Chris@0: use Symfony\Component\Process\Process; Chris@0: Chris@0: /** Chris@0: * Exception for failed processes. Chris@0: * Chris@0: * @author Johannes M. Schmitt Chris@0: */ Chris@0: class ProcessFailedException extends RuntimeException Chris@0: { Chris@0: private $process; Chris@0: Chris@0: public function __construct(Process $process) Chris@0: { Chris@0: if ($process->isSuccessful()) { Chris@0: throw new InvalidArgumentException('Expected a failed process, but the given process was successful.'); Chris@0: } Chris@0: Chris@0: $error = sprintf('The command "%s" failed.'."\n\nExit Code: %s(%s)\n\nWorking directory: %s", Chris@0: $process->getCommandLine(), Chris@0: $process->getExitCode(), Chris@0: $process->getExitCodeText(), Chris@0: $process->getWorkingDirectory() Chris@0: ); Chris@0: Chris@0: if (!$process->isOutputDisabled()) { Chris@0: $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", Chris@0: $process->getOutput(), Chris@0: $process->getErrorOutput() Chris@0: ); Chris@0: } Chris@0: Chris@0: parent::__construct($error); Chris@0: Chris@0: $this->process = $process; Chris@0: } Chris@0: Chris@0: public function getProcess() Chris@0: { Chris@0: return $this->process; Chris@0: } Chris@0: }