Newscoop\GimmeBundle\Controller\ExceptionController::showAction PHP Method

showAction() public method

Converts an Exception to a Response. TODO: change exceptions handling in listener - this controller should deal only with REST API exceptions.
public showAction ( Request $request, FlattenException $exception, Symfony\Component\HttpKernel\Log\DebugLoggerInterface $logger = null, string $format = 'html' ) : Response
$request Symfony\Component\HttpFoundation\Request Request
$exception Symfony\Component\HttpKernel\Exception\FlattenException A FlattenException instance
$logger Symfony\Component\HttpKernel\Log\DebugLoggerInterface A DebugLoggerInterface instance
$format string The format to use for rendering (html, xml, ...)
return Response Response instance
    public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
    {
        $urlMatcher = $this->container->get('router');
        try {
            $context = new \Symfony\Component\Routing\RequestContext($request->getPathInfo(), $request->getMethod());
            $urlMatcher->setContext($context);
            $match = $urlMatcher->match($context->getBaseUrl());
        } catch (\Exception $e) {
            return;
        }
        if (strpos($match['_route'], 'newscoop_gimme_') === false) {
            // Skip newscoop rest api exceptions
            $logger = $this->container->get('monolog.logger.sentry');
            $logger->log(\Psr\Log\LogLevel::CRITICAL, 'Uncaught exception', array('exception' => $exception));
            return;
        }
        return parent::showAction($request, $exception, $logger, $format);
    }