public function onConsoleException(ConsoleExceptionEvent $event)
    {
        /** @var SchedulerCommand $command */
        $command = $event->getCommand();

        if ($command->getName() != 'campaignchain:scheduler') {
            return;
        }

        // if scheduler is null exception happened in early stage
        // maybe email should be sent
        if (!$command->getScheduler()) {
            return;
        }

        /** @var Scheduler $scheduler */
        $scheduler = $command->getScheduler();

        $scheduler->setMessage($event->getException()->getMessage());
        $scheduler->setStatus(Scheduler::STATUS_ERROR);
        $scheduler->setExecutionEnd(new \DateTime());

        $this->em->persist($scheduler);
        $this->em->flush();

        $command->getIo()->error($scheduler->getMessage());
        $this->logger->critical($scheduler->getMessage());
    }