title: Console Exception and converting fatal errors into exception with ExceptionHandler
body: <p>my goal is to save exceptions and errors that occured during a console command.</p>
  
  <p>I'm using console.exception native symfony event, registered as follow :</p>
  
  <pre><code>kernel.listener.console:
          class: Evo\CronBundle\EventListener\ConsoleListener
          arguments: [@doctrine.orm.entity_manager]
          tags:
              - { name: kernel.event_listener, event: console.exception, method: onConsoleException }
  </code></pre>
  
  <p>i'm running the following custom command :</p>
  
  <pre><code>&lt;?php
  namespace Evo\CronBundle\Command;
  
  use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
  use Symfony\Component\Console\Input\InputInterface;
  use Symfony\Component\Console\Output\OutputInterface;
  use Evo\CronBundle\Event\CustomConsoleCommandEvent;
  use Evo\CronBundle\Event\CustomConsoleTerminateEvent;
  use Evo\CronBundle\Event\CustomConsoleExceptionEvent;
  use Evo\CronBundle\EvoCronEvents;
  
  
  class SendPostRegistrationMail1Command extends ContainerAwareCommand
  {
      /**
       * Configure command
       */
      protected function configure()
      {
          $this-&gt;setName('evo:send_post_registration_mail_1')
              -&gt;setDescription('Send Post Registration mail #1')
          ;
      }
  
      /**
       * Execute command
       *
       * @param InputInterface $input
       * @param OutputInterface $output
       * @return int|null|void
       */
      protected function execute(InputInterface $input, OutputInterface $output)
      {
          throw new \Symfony\Component\Debug\Exception\FatalErrorException('test');
      }
  }
  </code></pre>
  
  <p>The exception thrown triggers the event, where I can dump the exception I'll save into database :</p>
  
  <pre><code>&lt;?php
  
  namespace Evo\CronBundle\EventListener;
  
  use Doctrine\ORM\EntityManager;
  use Symfony\Component\Console\Event\ConsoleExceptionEvent;
  use Evo\CronBundle\Entity\CommandException;
  
  class ConsoleListener
  {
      /**
       * @var \Doctrine\ORM\EntityManager
       */
      private $em;
  
      /**
       * @var \Evo\CronBundle\Entity\CommandExecution
       */
      private $commandExecution;
  
      /**
       * Constructor
       *
       * @param EntityManager $em
       */
      public function __construct(EntityManager $em)
      {
          $this-&gt;em = $em;
      }
  
      /**
       * onConsoleException
       *
       * @param ConsoleExceptionEvent $event
       */
      public function onConsoleException(ConsoleExceptionEvent $event)
      {
          $exception = $event-&gt;getException();
  
          echo '&lt;pre&gt;';
          \Doctrine\Common\Util\Debug::dump($exception);
          echo '&lt;/pre&gt;';
          die();
      }
  }
  </code></pre>
  
  <p>displays </p>
  
  <pre><code>object(stdClass)#548 (6) {
    ["__CLASS__"]=&gt;
    string(53) "Symfony\Component\Debug\Exception\FatalErrorException"
    ["message"]=&gt;
    string(4) "test"
    ["code"]=&gt;
    int(0)
    ["file"]=&gt;
    string(94) "C:\server\www\evoportail-zfony\src\Evo\CronBundle\Command\SendPostRegistrationMail1Command.php"
    ["line"]=&gt;
    int(59)
    ["severity"]=&gt;
    int(1)
  }
  </code></pre>
  
  <p>In that case, the exception is correctly filled with message and the exception class is the one I threw in my command.</p>
  
  <p>But if I purposely triggers a php fatal error to make Symfony convert it into an exception using Exceptionhandler, for example :</p>
  
  <pre><code>/**
       * Execute command
       *
       * @param InputInterface $input
       * @param OutputInterface $output
       * @return int|null|void
       */
      protected function execute(InputInterface $input, OutputInterface $output)
      {
          strpos();
      }
  </code></pre>
  
  <p>The exception dumped in my event is the following :</p>
  
  <pre><code>object(stdClass)#642 (6) {
    ["__CLASS__"]=&gt;
    string(48) "Symfony\Component\Debug\Exception\DummyException"
    ["message"]=&gt;
    string(0) ""
    ["code"]=&gt;
    int(0)
    ["file"]=&gt;
    string(98) "C:\server\www\evoportail-zfony\vendor\symfony\symfony\src\Symfony\Component\Debug\ErrorHandler.php"
    ["line"]=&gt;
    int(162)
    ["severity"]=&gt;
    int(1)
  }
  </code></pre>
  
  <p>It's a DummyException thrown in \Symfony\Component\Debug\ErrorHandler.php and it has nothing related to the error triggered in my command. Did I miss something about this ErrorHandler supposed to convert errors into exceptions ?</p>