Skip to content

Commit

Permalink
Merge 17e5867 into ec3d1b3
Browse files Browse the repository at this point in the history
  • Loading branch information
sandergo90 committed Sep 7, 2018
2 parents ec3d1b3 + 17e5867 commit be3c62d
Showing 1 changed file with 8 additions and 5 deletions.
Expand Up @@ -2,10 +2,10 @@

namespace Kunstmaan\AdminBundle\EventListener;

use Psr\Log\LoggerInterface;
use Symfony\Component\Console\ConsoleEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Console\Event\ConsoleErrorEvent;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
* Class ConsoleExceptionSubscriber.
Expand All @@ -17,6 +17,7 @@ final class ConsoleExceptionSubscriber implements EventSubscriberInterface

/**
* ConsoleExceptionListener constructor.
*
* @param LoggerInterface $logger
*/
public function __construct(LoggerInterface $logger)
Expand All @@ -30,7 +31,7 @@ public function __construct(LoggerInterface $logger)
public static function getSubscribedEvents()
{
return [
ConsoleEvents::ERROR => 'onConsoleError'
ConsoleEvents::ERROR => 'onConsoleError',
];
}

Expand All @@ -42,7 +43,9 @@ public function onConsoleError(ConsoleErrorEvent $event)
$command = $event->getCommand();
$error = $event->getError();

$this->logCommandError($command, $error);
if (null !== $command) {
$this->logCommandError($command, $error);
}
}

/**
Expand All @@ -61,4 +64,4 @@ private function logCommandError($command, $error)
);
$this->logger->error($message, ['error' => $error]);
}
}
}

0 comments on commit be3c62d

Please sign in to comment.