@@ -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