@@ -271,12 +271,7 @@ public function handle(array $argv)
271
271
$ this ->doAction ($ command );
272
272
$ exitCode = 0 ;
273
273
} 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 );
280
275
}
281
276
282
277
return ($ this ->onExit )($ exitCode );
@@ -311,20 +306,25 @@ protected function aliasesFor(Command $command): array
311
306
public function showHelp ()
312
307
{
313
308
$ writer = $ this ->io ()->writer ();
314
- $ helper = new OutputHelper ($ writer );
315
-
316
309
$ header = "{$ this ->name }, version {$ this ->version }" ;
317
310
$ footer = 'Run `<command> --help` for specific help ' ;
318
311
319
312
if ($ this ->logo ) {
320
313
$ writer ->write ($ this ->logo , true );
321
314
}
322
315
323
- $ helper ->showCommandsHelp ($ this ->commands (), $ header , $ footer );
316
+ $ this -> outputHelper () ->showCommandsHelp ($ this ->commands (), $ header , $ footer );
324
317
325
318
return ($ this ->onExit )();
326
319
}
327
320
321
+ protected function outputHelper (): OutputHelper
322
+ {
323
+ $ writer = $ this ->io ()->writer ();
324
+
325
+ return new OutputHelper ($ writer );
326
+ }
327
+
328
328
/**
329
329
* Invoke command action.
330
330
*
0 commit comments