diff --git a/README.md b/README.md index 90fca33..18398df 100644 --- a/README.md +++ b/README.md @@ -194,7 +194,7 @@ This will spin-up two servers, one in port `9515`, and the second one in port `9 be used with the other three other actions: `stop`, `restart`, and `status`. > **Note**: -> This comand can only be use with the first four actions: `start`, `stop`, `restart`, and `status`. +> This option only can be used with the first four actions: `start`, `stop`, `restart`, and `status`. The second one is just to specify where to search for the Chrome Driver binary, you just need to specify the option `--path`. diff --git a/app/Commands/DriverManagerCommand.php b/app/Commands/DriverManagerCommand.php index 2f2ecbb..4a401eb 100644 --- a/app/Commands/DriverManagerCommand.php +++ b/app/Commands/DriverManagerCommand.php @@ -2,6 +2,7 @@ namespace App\Commands; +use App\Commands\Exceptions\DoesNotSupportWindowsException; use App\Commands\Exceptions\FailCommandException; use App\OperatingSystem; use Illuminate\Console\Command; @@ -100,7 +101,7 @@ protected function start(string $port): int return self::FAILURE; } - } catch (\Exception) { + } catch (DoesNotSupportWindowsException) { warning('We are running on windows and we cannot start the server'); return self::FAILURE; @@ -124,7 +125,7 @@ public function stop(string $port): int try { $pid = $this->getProcessID($port); - } catch (\Exception) { + } catch (DoesNotSupportWindowsException) { warning('We are running on windows and we cannot stop the server'); return self::FAILURE; @@ -149,7 +150,7 @@ protected function restart(string $port): int try { $pid = $this->getProcessID($port); - } catch (\Exception) { + } catch (DoesNotSupportWindowsException) { warning('We are running on windows and we cannot restart the server'); return self::FAILURE; @@ -176,7 +177,7 @@ protected function status(string $port): int try { $pid = $this->getProcessID($port); - } catch (\Exception) { + } catch (DoesNotSupportWindowsException) { warning('We are running on windows and we cannot be sure if the server is running, but we will try to check'); } @@ -210,7 +211,7 @@ protected function list(): int try { $result = $this->getProcessIDs(); - } catch (\Exception) { + } catch (DoesNotSupportWindowsException) { warning('We are running on windows and we cannot list the servers'); return self::FAILURE; @@ -234,7 +235,7 @@ protected function kill(): int { try { $pids = $this->getProcessIDs(); - } catch (\Exception) { + } catch (DoesNotSupportWindowsException) { warning('We are running on windows and we cannot stop the servers'); return self::FAILURE; @@ -294,7 +295,7 @@ protected function command(string $cmd, array $with): ProcessResult protected function getProcessID(string $port): ?int { if ($this->onWindows()) { - throw new \Exception('We cannot get a server PID on Windows'); + throw new DoesNotSupportWindowsException; } $process = $this->command('pid', ['{options}' => '--port='.$port]); @@ -307,7 +308,7 @@ protected function getProcessID(string $port): ?int protected function getProcessIDs(): ?Collection { if ($this->onWindows()) { - throw new \Exception('We cannot get the servers PID on Windows'); + throw new DoesNotSupportWindowsException; } $process = $this->command('pid', ['{options}' => '']); diff --git a/app/Commands/Exceptions/DoesNotSupportWindowsException.php b/app/Commands/Exceptions/DoesNotSupportWindowsException.php new file mode 100644 index 0000000..d51f5f9 --- /dev/null +++ b/app/Commands/Exceptions/DoesNotSupportWindowsException.php @@ -0,0 +1,11 @@ +