From fd26c83cfd341b2521902fb5fa8a9b5e6a5455a7 Mon Sep 17 00:00:00 2001 From: Bastian Allgeier Date: Mon, 5 Feb 2024 17:19:07 +0100 Subject: [PATCH] Improve exception handling for argument parsing --- src/CLI/CLI.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/CLI/CLI.php b/src/CLI/CLI.php index 58614e1..58a2471 100644 --- a/src/CLI/CLI.php +++ b/src/CLI/CLI.php @@ -518,12 +518,11 @@ public function run(?string $name = null, ...$args): void ...$args ]; - $exception = null; - try { $this->climate->arguments->parse($argv); } catch (Throwable $e) { - $exception = $e; + $this->error($e->getMessage()); + exit; } // enable quiet mode @@ -537,10 +536,6 @@ public function run(?string $name = null, ...$args): void return; } - if ($exception !== null) { - throw $exception; - } - $command['command']($this); }