39
39
use Symfony \Component \Console \Event \ConsoleTerminateEvent ;
40
40
use Symfony \Component \Console \Exception \CommandNotFoundException ;
41
41
use Symfony \Component \Console \Exception \LogicException ;
42
- use Symfony \Component \Debug \Exception \FatalThrowableError ;
43
42
use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
44
43
45
44
/**
@@ -120,13 +119,8 @@ public function run(InputInterface $input = null, OutputInterface $output = null
120
119
$ this ->configureIO ($ input , $ output );
121
120
122
121
try {
123
- $ e = null ;
124
122
$ exitCode = $ this ->doRun ($ input , $ output );
125
- } catch (\Exception $ e ) {
126
123
} catch (\Throwable $ e ) {
127
- }
128
-
129
- if (null !== $ e ) {
130
124
if (!$ this ->catchExceptions || !$ e instanceof \Exception) {
131
125
throw $ e ;
132
126
}
@@ -201,11 +195,12 @@ public function doRun(InputInterface $input, OutputInterface $output)
201
195
if (null !== $ this ->dispatcher ) {
202
196
$ event = new ConsoleErrorEvent ($ input , $ output , $ e );
203
197
$ this ->dispatcher ->dispatch (ConsoleEvents::ERROR , $ event );
204
- $ e = $ event ->getError ();
205
198
206
199
if (0 === $ event ->getExitCode ()) {
207
200
return 0 ;
208
201
}
202
+
203
+ $ e = $ event ->getError ();
209
204
}
210
205
211
206
throw $ e ;
@@ -849,7 +844,6 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
849
844
}
850
845
851
846
$ event = new ConsoleCommandEvent ($ command , $ input , $ output );
852
- $ e = null ;
853
847
854
848
try {
855
849
$ this ->dispatcher ->dispatch (ConsoleEvents::COMMAND , $ event );
@@ -862,10 +856,9 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
862
856
} catch (\Throwable $ e ) {
863
857
$ event = new ConsoleErrorEvent ($ input , $ output , $ e , $ command );
864
858
$ this ->dispatcher ->dispatch (ConsoleEvents::ERROR , $ event );
865
- $ e = $ event ->getError ();
866
859
867
860
if (0 !== $ exitCode = $ event ->getExitCode ()) {
868
- throw $ e ;
861
+ throw $ event -> getError () ;
869
862
}
870
863
} finally {
871
864
$ event = new ConsoleTerminateEvent ($ command , $ input , $ output , $ exitCode );
0 commit comments