diff --git a/src/Application.php b/src/Application.php index 92f1f0e..3b0b4be 100644 --- a/src/Application.php +++ b/src/Application.php @@ -271,12 +271,7 @@ public function handle(array $argv) $this->doAction($command); $exitCode = 0; } catch (\Throwable $e) { - $this->io()->error($e->getMessage(), true); - - if (!$e instanceof Exception) { - $location = \get_class($e) . ' thrown in ' . $e->getFile() . ' on line ' . $e->getLine(); - $this->io()->bgRed($location, true); - } + $this->outputHelper()->printTrace($e); } return ($this->onExit)($exitCode); @@ -311,8 +306,6 @@ protected function aliasesFor(Command $command): array public function showHelp() { $writer = $this->io()->writer(); - $helper = new OutputHelper($writer); - $header = "{$this->name}, version {$this->version}"; $footer = 'Run ` --help` for specific help'; @@ -320,11 +313,18 @@ public function showHelp() $writer->write($this->logo, true); } - $helper->showCommandsHelp($this->commands(), $header, $footer); + $this->outputHelper()->showCommandsHelp($this->commands(), $header, $footer); return ($this->onExit)(); } + protected function outputHelper(): OutputHelper + { + $writer = $this->io()->writer(); + + return new OutputHelper($writer); + } + /** * Invoke command action. *