Skip to content

Commit

Permalink
Rename exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
luzrain committed Sep 27, 2024
1 parent 0c669c2 commit f88f99e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Luzrain\PHPStreamServer\Server;

final class AlreadyRunningException extends \Exception
final class ServerAlreadyRunningException extends \Exception
{
public function __construct()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Luzrain\PHPStreamServer\Server;

final class NotRunningException extends \Exception
final class ServerIsShutdownException extends \Exception
{
public function __construct()
{
Expand Down
20 changes: 10 additions & 10 deletions src/Internal/MasterProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

use Amp\Future;
use Luzrain\PHPStreamServer\Console\StdoutHandler;
use Luzrain\PHPStreamServer\Exception\AlreadyRunningException;
use Luzrain\PHPStreamServer\Exception\NotRunningException;
use Luzrain\PHPStreamServer\Exception\ServerAlreadyRunningException;
use Luzrain\PHPStreamServer\Exception\ServerIsShutdownException;
use Luzrain\PHPStreamServer\Exception\PHPStreamServerException;
use Luzrain\PHPStreamServer\Internal\MessageBus\Message;
use Luzrain\PHPStreamServer\Internal\MessageBus\MessageBus;
Expand Down Expand Up @@ -109,12 +109,12 @@ public function addPlugin(Plugin ...$plugins): void
}

/**
* @throws AlreadyRunningException
* @throws ServerAlreadyRunningException
*/
public function run(bool $daemonize = false): int
{
if ($this->isRunning()) {
throw new AlreadyRunningException();
throw new ServerAlreadyRunningException();
}

if ($daemonize && $this->doDaemonize()) {
Expand Down Expand Up @@ -248,12 +248,12 @@ private function onMasterShutdown(): void
}

/**
* @throws NotRunningException
* @throws ServerIsShutdownException
*/
public function stop(int $code = 0): void
{
if (!$this->isRunning()) {
throw new NotRunningException();
throw new ServerIsShutdownException();
}

// If it called from outside working process
Expand Down Expand Up @@ -285,12 +285,12 @@ public function stop(int $code = 0): void
}

/**
* @throws NotRunningException
* @throws ServerIsShutdownException
*/
public function reload(): void
{
if (!$this->isRunning()) {
throw new NotRunningException();
throw new ServerIsShutdownException();
}

// If it called from outside working process
Expand Down Expand Up @@ -377,12 +377,12 @@ public function unsubscribe(string $class, \Closure $closure): void
* @template T
* @param Message<T> $message
* @return Future<T>
* @throws NotRunningException
* @throws ServerIsShutdownException
*/
public function dispatch(Message $message): Future
{
if (!$this->isRunning()) {
throw new NotRunningException();
throw new ServerIsShutdownException();
}

if ($this->status === Status::RUNNING) {
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/System/Command/ReloadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Luzrain\PHPStreamServer\Console\Command;
use Luzrain\PHPStreamServer\Console\Options;
use Luzrain\PHPStreamServer\Exception\NotRunningException;
use Luzrain\PHPStreamServer\Exception\ServerIsShutdownException;

final class ReloadCommand extends Command
{
Expand All @@ -17,7 +17,7 @@ public function execute(Options $options): int
{
try {
$this->masterProcess->reload();
} catch (NotRunningException $e) {
} catch (ServerIsShutdownException $e) {
echo \sprintf("<color;bg=red>%s</>\n", $e->getMessage());
return 1;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/System/Command/StartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Luzrain\PHPStreamServer\Console\Command;
use Luzrain\PHPStreamServer\Console\Options;
use Luzrain\PHPStreamServer\Console\Table;
use Luzrain\PHPStreamServer\Exception\AlreadyRunningException;
use Luzrain\PHPStreamServer\Exception\ServerAlreadyRunningException;
use Luzrain\PHPStreamServer\Internal\ServerStatus\ServerStatus;
use Luzrain\PHPStreamServer\Internal\ServerStatus\WorkerProcessInfo;
use Luzrain\PHPStreamServer\Server;
Expand Down Expand Up @@ -66,7 +66,7 @@ public function execute(Options $options): int

try {
return $this->masterProcess->run($isDaemon);
} catch (AlreadyRunningException $e) {
} catch (ServerAlreadyRunningException $e) {
echo \sprintf("<color;bg=red>%s</>\n", $e->getMessage());
return 1;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/System/Command/StopCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Luzrain\PHPStreamServer\Console\Command;
use Luzrain\PHPStreamServer\Console\Options;
use Luzrain\PHPStreamServer\Exception\NotRunningException;
use Luzrain\PHPStreamServer\Exception\ServerIsShutdownException;

final class StopCommand extends Command
{
Expand All @@ -17,7 +17,7 @@ public function execute(Options $options): int
{
try {
$this->masterProcess->stop();
} catch (NotRunningException $e) {
} catch (ServerIsShutdownException $e) {
echo \sprintf("<color;bg=red>%s</>\n", $e->getMessage());
return 1;
}
Expand Down

0 comments on commit f88f99e

Please sign in to comment.