-
Notifications
You must be signed in to change notification settings - Fork 10.9k
/
ProcessFailedException.php
42 lines (34 loc) · 1.05 KB
/
ProcessFailedException.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace Illuminate\Process\Exceptions;
use Illuminate\Contracts\Process\ProcessResult;
use RuntimeException;
class ProcessFailedException extends RuntimeException
{
/**
* The process result instance.
*
* @var \Illuminate\Contracts\Process\ProcessResult
*/
public $result;
/**
* Create a new exception instance.
*
* @param \Illuminate\Contracts\Process\ProcessResult $result
* @return void
*/
public function __construct(ProcessResult $result)
{
$this->result = $result;
$error = sprintf('The command "%s" failed.'."\n\nExit Code: %s",
$result->command(),
$result->exitCode(),
);
if (! empty($result->output())) {
$error .= sprintf("\n\nOutput:\n================\n%s", $result->output());
}
if (! empty($result->errorOutput())) {
$error .= sprintf("\n\nError Output:\n================\n%s", $result->errorOutput());
}
parent::__construct($error, $result->exitCode() ?? 1);
}
}