mirror of
https://github.com/n3w/helpers-functions-cli.git
synced 2025-12-19 12:43:22 +00:00
Added run_command() function and RunCommandFailedException exception
This commit is contained in:
parent
feb7956bb0
commit
3ccfe2477f
2 changed files with 81 additions and 0 deletions
30
src/Cli/Exceptions/RunCommandFailedException.php
Normal file
30
src/Cli/Exceptions/RunCommandFailedException.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pointybeard\Helpers\Functions\Cli\Exceptions;
|
||||
|
||||
use pointybeard\Helpers\Exceptions\ReadableTrace;
|
||||
|
||||
class RunCommandFailedException extends ReadableTrace\ReadableTraceException
|
||||
{
|
||||
private $command;
|
||||
private $error;
|
||||
|
||||
public function __construct(string $command, string $error, int $code = 0, \Exception $previous = null)
|
||||
{
|
||||
$this->command = $command;
|
||||
$this->error = $error;
|
||||
parent::__construct("Failed to run command. Returned: {$error}", $code, $previous);
|
||||
}
|
||||
|
||||
public function getCommand(): string
|
||||
{
|
||||
return $this->command;
|
||||
}
|
||||
|
||||
public function getError(): string
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue