Contributed by
Wouter De Jong
in #18140.

The ConsoleEvents::EXCEPTION event is triggered as soon as an exception is thrown while running a console command. It's useful to change the exceptions or handle them in some way before the application throws them.

However, this event is only dispatched for exceptions during the execution of Command#execute(). All other exceptions (e.g. the ones thrown by listeners) are silently caught in the Application#doRunCommand() method. This means that there is no way to override exception handling in those cases.

In Symfony 3.3, we decided to improve the exception handling in commands with the introduction of a new ConsoleEvents::ERROR event and the deprecation of the ConsoleEvents::EXCEPTION event. A new ConsoleErrorEvent class has also been created and the ConsoleExceptionEvent class has been deprecated too.

In practice, the changes required in your application will be minimal. Just listen to the new ConsoleEvents::ERROR event and handle the exceptions as before, with the added possibility of handling more exceptions that may occur during the command execution.