Skip to content

Commit

Permalink
Merge pull request #80 from softspring/show-error-on-error-pages
Browse files Browse the repository at this point in the history
Show error on error pages
  • Loading branch information
javihgil committed May 16, 2023
2 parents 5503c96 + c8dd73e commit 83658f5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/EventListener/ErrorPageListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Softspring\CmsBundle\EventListener;

use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
Expand All @@ -12,10 +13,12 @@
class ErrorPageListener implements EventSubscriberInterface
{
protected Environment $twig;
protected LoggerInterface $logger;

public function __construct(Environment $twig)
public function __construct(Environment $twig, LoggerInterface $cmsLogger)
{
$this->twig = $twig;
$this->logger = $cmsLogger;
}

public static function getSubscribedEvents(): array
Expand Down Expand Up @@ -82,8 +85,7 @@ protected function renderErrorTemplate(array $templates, string $locale): ?strin
}
} catch (\Exception $e) {
// do not throw any exception, try render next template
// maybe log something
$m = $e->getMessage();
$this->logger->error(sprintf('ERROR RENDERING ERROR PAGE (%s): %s', $template, $e->getMessage()));
}
}

Expand Down

0 comments on commit 83658f5

Please sign in to comment.