@@ -97,13 +97,24 @@ Whenever an exception is thrown by a command, the ``ConsoleEvents::EXCEPTION``
9797event is dispatched. A listener can wrap or change the exception or do
9898anything useful before the exception is thrown by the application.
9999
100+ The ``ConsoleEvents::ERROR `` Event
101+ ----------------------------------
102+
103+ **Typical Purposes **: Handle exceptions thrown during the execution of a
104+ command.
105+
106+ Whenever an exception is thrown by a command, including those triggered from
107+ event listeners, the ``ConsoleEvents::ERROR `` event is dispatched. A listener
108+ can wrap or change the exception or do anything useful before the exception is
109+ thrown by the application.
110+
100111Listeners receive a
101- :class: `Symfony\\ Component\\ Console\\ Event\\ ConsoleExceptionEvent ` event::
112+ :class: `Symfony\\ Component\\ Console\\ Event\\ ConsoleErrorEvent ` event::
102113
103- use Symfony\Component\Console\Event\ConsoleExceptionEvent ;
114+ use Symfony\Component\Console\Event\ConsoleErrorEvent ;
104115 use Symfony\Component\Console\ConsoleEvents;
105116
106- $dispatcher->addListener(ConsoleEvents::EXCEPTION , function (ConsoleExceptionEvent $event) {
117+ $dispatcher->addListener(ConsoleEvents::ERROR , function (ConsoleErrorEvent $event) {
107118 $output = $event->getOutput();
108119
109120 $command = $event->getCommand();
@@ -114,22 +125,9 @@ Listeners receive a
114125 $exitCode = $event->getExitCode();
115126
116127 // changes the exception to another one
117- $event->setException (new \LogicException('Caught exception', $exitCode, $event->getException ()));
128+ $event->setError (new \LogicException('Caught exception', $exitCode, $event->getError ()));
118129 });
119130
120- The ``ConsoleEvents::ERROR `` Event
121- ----------------------------------
122-
123- .. versionadded :: 3.3
124- The ``ConsoleEvents::ERROR `` event was introduced in Symfony 3.3.
125-
126- **Typical Purposes **: Handle exceptions thrown during the execution of a
127- command.
128-
129- This event is an improved version of the ``ConsoleEvents::EXCEPTION `` event,
130- because it can handle every exception thrown during the execution of a command,
131- including those triggered from event listeners.
132-
133131The ``ConsoleEvents::TERMINATE `` Event
134132--------------------------------------
135133
0 commit comments