Skip to content

Commit 57de69f

Browse files
committed
added an exception for failed processes
1 parent edac48a commit 57de69f

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
namespace Symfony\Component\Process\Exception;
13+
14+
/**
15+
* Marker Interface for the Process Component.
16+
*
17+
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
18+
*/
19+
interface ExceptionInterface
20+
{
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
namespace Symfony\Component\Process\Exception;
13+
14+
use Symfony\Component\Process\Process;
15+
16+
/**
17+
* Exception for failed processes.
18+
*
19+
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
20+
*/
21+
class ProcessFailedException extends RuntimeException
22+
{
23+
private $process;
24+
25+
public function __construct(Process $process)
26+
{
27+
if ($process->isSuccessful()) {
28+
throw new \InvalidArgumentException('Expected a failed process, but the given process was successful.');
29+
}
30+
31+
parent::__construct(sprintf('The command "%s" failed.'."\n\nOutput:\n================\n".$process->getOutput()."\n\nError Output:\n================\n".$process->getErrorOutput()));
32+
33+
$this->process = $process;
34+
}
35+
36+
public function getProcess()
37+
{
38+
return $this->process;
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
namespace Symfony\Component\Process\Exception;
13+
14+
/**
15+
* RuntimeException for the Process Component.
16+
*
17+
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
18+
*/
19+
class RuntimeException extends \RuntimeException implements ExceptionInterface
20+
{
21+
}

0 commit comments

Comments
 (0)