src/Controller/ErrorController.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Component\HttpFoundation\Response;
  4. use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. class ErrorController extends AbstractController
  7. {
  8.     public function show(\Throwable $exception): Response
  9.     {
  10.         $statusCode $exception instanceof HttpExceptionInterface $exception->getStatusCode() : 500;
  11.         if ($statusCode == 404) {
  12.             return $this->render('error/error404.html.twig', [
  13.                 'status_code' => $statusCode,
  14.                 'message' => $exception->getMessage(),
  15.                 'exception' => $exception,
  16.             ]);
  17.         } else {
  18.             return $this->render('error/error.html.twig', [
  19.                 'status_code' => $statusCode,
  20.                 'message' => $exception->getMessage(),
  21.                 'exception' => $exception,
  22.             ]);
  23.         }
  24.         
  25.     }
  26. }