Add an error view Co-authored-by: vivien.dufour <vivien.dufour@etu.uca.fr> Co-authored-by: vidufour1 <Vivien.DUFOUR@etu.uca.fr> Reviewed-on: #10pull/13/head
parent
86373fb81b
commit
4aa2bde233
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
require_once __DIR__ . "/../react-display.php";
|
||||
use \Twig\Environment;
|
||||
use Twig\Error\LoaderError;
|
||||
use Twig\Error\RuntimeError;
|
||||
use Twig\Error\SyntaxError;
|
||||
|
||||
class ErrorController
|
||||
{
|
||||
public static function displayFailures(array $failures, Environment $twig) {
|
||||
try {
|
||||
$twig->display("error.html.twig", ['failures' => $failures]);
|
||||
} catch (LoaderError | RuntimeError | SyntaxError $e) {
|
||||
echo "Twig error: $e";
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Error</title>
|
||||
<style>
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #da6110;
|
||||
text-align: center;
|
||||
margin-bottom: 15px
|
||||
}
|
||||
|
||||
h2 {
|
||||
text-align: center;
|
||||
margin-bottom: 15px;
|
||||
margin-top: 15px
|
||||
}
|
||||
|
||||
.button {
|
||||
display: block;
|
||||
cursor : pointer;
|
||||
background-color: white;
|
||||
color : black;
|
||||
text-align: center;
|
||||
font-size: 20px;
|
||||
border-radius: 12px;
|
||||
border : 2px solid #da6110;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
background-color: #da6110
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>IQBall</h1>
|
||||
|
||||
{% for fail in failures %}
|
||||
<h2>{{ fail.getKind() }} : {{ fail.getMessage() }}</h2>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
<button class="button" onclick="location.href='/'" type="button">Retour à la page d'accueil</button>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in new issue