You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Application-Web/src/Controller/ErrorController.php

35 lines
817 B

<?php
namespace App\Controller;
require_once __DIR__ . "/../react-display.php";
use App\Gateway\FormResultGateway;
use \Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Error\SyntaxError;
class ErrorController
{
private FormResultGateway $gateway;
private Environment $twig;
/**
* @param FormResultGateway $gateway
*/
public function __construct(FormResultGateway $gateway, Environment $twig)
{
$this->gateway = $gateway;
$this->twig = $twig;
}
public function displayError($error) {
$error = array("error" => $error);
try {
echo $this->twig->render('error.html.twig', $error);
} catch (LoaderError | RuntimeError | SyntaxError $e) {
echo "Twig error: $e";
}
}
}