ProcessFailedException.php 1.1 KB

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