Remove unnecessary exception class ProcessControlException

This commit is contained in:
Joop Schilder 2020-12-14 14:32:35 +01:00
parent 4db3a66030
commit 0a4865f597
2 changed files with 2 additions and 25 deletions

View File

@ -1,23 +0,0 @@
<?php
namespace Toalett\Multiprocessing\Exception;
use RuntimeException;
class ProcessControlException extends RuntimeException
{
private function __construct(string $functionName)
{
parent::__construct(sprintf('call to \'%s\' failed', $functionName));
}
public static function forkFailed(): self
{
return new self('pcntl_fork');
}
public static function waitFailed(): self
{
return new self('pcntl_wait');
}
}

View File

@ -5,8 +5,8 @@ namespace Toalett\Multiprocessing;
use Countable;
use Evenement\EventEmitterInterface;
use Evenement\EventEmitterTrait;
use RuntimeException;
use Throwable;
use Toalett\Multiprocessing\Exception\ProcessControlException;
use Toalett\Multiprocessing\ProcessControl\PCNTL;
use Toalett\Multiprocessing\ProcessControl\ProcessControl;
use Toalett\Multiprocessing\ProcessControl\Wait;
@ -59,7 +59,7 @@ class Workers implements Countable, EventEmitterInterface
{
$fork = $this->processControl->fork();
if ($fork->failed()) {
throw ProcessControlException::forkFailed();
throw new RuntimeException('Could not fork process');
}
if ($fork->isChild()) {