src/Controller/ErrorController.php
/**
     * Show an exception. Mainly used for custom 404 pages, otherwise falls back
     * to Symfony's error handling
     */
Show an exception. Mainly used for custom 404 pages, otherwise falls back
to Symfony's error handling
Show an exception . Mainly used for custom 404 pages otherwise falls back to Symfony ' s error handling
public function showAction(Environment $twig, \Throwable $exception): Response
    {
        if (method_exists($exception, 'getStatusCode')) {
            $code = $exception->getStatusCode();
        } else {
            $code = Response::HTTP_INTERNAL_SERVER_ERROR;
        }
        try {
            $twig->addGlobal('exception', $exception);
        } catch (\LogicException $e) {
        }
        if ($code === Response::HTTP_SERVICE_UNAVAILABLE || $this->isMaintenanceEnabled($code)) {
            $twig->addGlobal('exception', $exception);
            return $this->showMaintenance();
        }
        if ($code === Response::HTTP_NOT_FOUND) {
            return $this->showNotFound();
        }
        if ($code === Response::HTTP_FORBIDDEN) {
            return $this->showForbidden();
        }
        $prod = mb_strtolower($this->parameterBag->get('kernel.environment')) === 'prod';
        if ($code === Response::HTTP_INTERNAL_SERVER_ERROR && $prod && $this->config->get('general/internal_server_error')) {
            return $this->showInternalServerError();
        }
        return parent::__invoke($exception);
    }
public function showAction ( Environment $ twig , \ Throwable $ exception ) : Response { if ( method_exists ( $ exception , 'getStatusCode' ) ) { $ code = $ exception -> getStatusCode ( ) ; } else { $ code = Response :: HTTP_INTERNAL_SERVER_ERROR ; } try { $ twig -> addGlobal ( 'exception' , $ exception ) ; } catch ( \ LogicException $ e ) { } if ( $ code === Response :: HTTP_SERVICE_UNAVAILABLE || $ this -> isMaintenanceEnabled ( $ code ) ) { $ twig -> addGlobal ( 'exception' , $ exception ) ; return $ this -> showMaintenance ( ) ; } if ( $ code === Response :: HTTP_NOT_FOUND ) { return $ this -> showNotFound ( ) ; } if ( $ code === Response :: HTTP_FORBIDDEN ) { return $ this -> showForbidden ( ) ; } $ prod = mb_strtolower ( $ this -> parameterBag -> get ( 'kernel.environment' ) ) === 'prod' ; if ( $ code === Response :: HTTP_INTERNAL_SERVER_ERROR && $ prod && $ this -> config -> get ( 'general/internal_server_error' ) ) { return $ this -> showInternalServerError ( ) ; } return parent :: __invoke ( $ exception ) ; }
Show an exception.
Show an exception .
// Fine! We'll just _not_ add the exception to the global scope! // If not a 404, we'll let Symfony handle it as usual.