diff --git a/src/EventListener/ExceptionListener.php b/src/EventListener/ExceptionListener.php
index 85e4e9e..20e2d40 100644
--- a/src/EventListener/ExceptionListener.php
+++ b/src/EventListener/ExceptionListener.php
@@ -34,7 +34,10 @@ class ExceptionListener
}
$response = new Response(
- $this->twig->render($template, ['status_code' => $statusCode]),
+ $this->twig->render($template, [
+ 'status_code' => $statusCode,
+ 'error_message' => $exception->getMessage(),
+ ]),
$statusCode,
);
diff --git a/templates/error/500.html.twig b/templates/error/500.html.twig
index fe51320..7d0207a 100644
--- a/templates/error/500.html.twig
+++ b/templates/error/500.html.twig
@@ -13,7 +13,12 @@
{{ status_code }}
Erreur serveur
-
Une erreur inattendue s'est produite. Nos equipes ont ete notifiees.
+
Une erreur inattendue s'est produite. Nos equipes ont ete notifiees.
+ {% if error_message is defined and error_message %}
+
+ {% endif %}
Retour a l'accueil
diff --git a/tests/EventListener/ExceptionListenerTest.php b/tests/EventListener/ExceptionListenerTest.php
index 372103e..f19bcfb 100644
--- a/tests/EventListener/ExceptionListenerTest.php
+++ b/tests/EventListener/ExceptionListenerTest.php
@@ -43,7 +43,7 @@ class ExceptionListenerTest extends TestCase
$twig = $this->createMock(Environment::class);
$twig->expects(self::once())
->method('render')
- ->with('error/404.html.twig', ['status_code' => 404])
+ ->with('error/404.html.twig', ['status_code' => 404, 'error_message' => 'Not found'])
->willReturn('
404
');
$listener = new ExceptionListener($twig, 'prod');
@@ -61,7 +61,7 @@ class ExceptionListenerTest extends TestCase
$twig = $this->createMock(Environment::class);
$twig->expects(self::once())
->method('render')
- ->with('error/500.html.twig', ['status_code' => 500])
+ ->with('error/500.html.twig', ['status_code' => 500, 'error_message' => 'Server error'])
->willReturn('
500
');
$listener = new ExceptionListener($twig, 'prod');
@@ -78,7 +78,7 @@ class ExceptionListenerTest extends TestCase
$twig = $this->createMock(Environment::class);
$twig->expects(self::once())
->method('render')
- ->with('error/500.html.twig', ['status_code' => 403])
+ ->with('error/500.html.twig', ['status_code' => 403, 'error_message' => 'Forbidden'])
->willReturn('
403
');
$listener = new ExceptionListener($twig, 'prod');