Display error message on 500 error page
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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,
|
||||
);
|
||||
|
||||
|
||||
@@ -13,7 +13,12 @@
|
||||
<div class="border-4 border-gray-900 bg-white shadow-[6px_6px_0px_rgba(0,0,0,1)] p-12">
|
||||
<div class="text-8xl font-black uppercase tracking-tighter mb-4">{{ status_code }}</div>
|
||||
<h1 class="text-3xl font-black uppercase tracking-tighter italic mb-4">Erreur serveur</h1>
|
||||
<p class="font-bold text-gray-500 italic mb-8">Une erreur inattendue s'est produite. Nos equipes ont ete notifiees.</p>
|
||||
<p class="font-bold text-gray-500 italic mb-4">Une erreur inattendue s'est produite. Nos equipes ont ete notifiees.</p>
|
||||
{% if error_message is defined and error_message %}
|
||||
<div class="card-brutal-red mb-8">
|
||||
<p class="text-sm font-mono break-all">{{ error_message }}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="/" class="btn-brutal font-black uppercase text-sm tracking-widest hover:bg-indigo-600 hover:text-white transition-all">
|
||||
Retour a l'accueil
|
||||
</a>
|
||||
|
||||
@@ -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('<h1>404</h1>');
|
||||
|
||||
$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('<h1>500</h1>');
|
||||
|
||||
$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('<h1>403</h1>');
|
||||
|
||||
$listener = new ExceptionListener($twig, 'prod');
|
||||
|
||||
Reference in New Issue
Block a user