Skip to content

Commit 7b5080e

Browse files
committed
refactor(app): output helper instantiation and print trace
1 parent 1783561 commit 7b5080e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/Application.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,7 @@ public function handle(array $argv)
271271
$this->doAction($command);
272272
$exitCode = 0;
273273
} catch (\Throwable $e) {
274-
$this->io()->error($e->getMessage(), true);
275-
276-
if (!$e instanceof Exception) {
277-
$location = \get_class($e) . ' thrown in ' . $e->getFile() . ' on line ' . $e->getLine();
278-
$this->io()->bgRed($location, true);
279-
}
274+
$this->outputHelper()->printTrace($e);
280275
}
281276

282277
return ($this->onExit)($exitCode);
@@ -311,20 +306,25 @@ protected function aliasesFor(Command $command): array
311306
public function showHelp()
312307
{
313308
$writer = $this->io()->writer();
314-
$helper = new OutputHelper($writer);
315-
316309
$header = "{$this->name}, version {$this->version}";
317310
$footer = 'Run `<command> --help` for specific help';
318311

319312
if ($this->logo) {
320313
$writer->write($this->logo, true);
321314
}
322315

323-
$helper->showCommandsHelp($this->commands(), $header, $footer);
316+
$this->outputHelper()->showCommandsHelp($this->commands(), $header, $footer);
324317

325318
return ($this->onExit)();
326319
}
327320

321+
protected function outputHelper(): OutputHelper
322+
{
323+
$writer = $this->io()->writer();
324+
325+
return new OutputHelper($writer);
326+
}
327+
328328
/**
329329
* Invoke command action.
330330
*

0 commit comments

Comments
 (0)