Skip to content

Commit 810aa5d

Browse files
author
Dylan
committed
add Particular Error Scenarios
1 parent 9926b76 commit 810aa5d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

controller/error_pages.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,3 +336,23 @@ time and again, you can have just one (or several) listeners deal with them.
336336
your application (like :class:`Symfony\\Component\\Security\\Core\\Exception\\AccessDeniedException`)
337337
and takes measures like redirecting the user to the login page, logging them
338338
out and other things.
339+
340+
Particular Error Scenarios
341+
--------------------------
342+
343+
There are a multitude of error scenarios when customising error pages. Here are a few of them:
344+
345+
### PHP Errors
346+
347+
If you encounter PHP errors like TypeError or Division by zero, you can customize the error handling by overriding the `Symfony\\Component\\HttpKernel\\Controller\\ErrorController` using the service.yaml when in the production environment. Although the default error pages may not capture all PHP errors, you can still utilize Twig for rendering (:ref:`override the default error controller <custom-error-controller>`).
348+
349+
### Errors Before Twig Initialization
350+
351+
In cases where errors occur before Twig is initialized, such as when there is no connection to the database, you can set the template of HtmlErrorRenderer on your kernel:
352+
353+
```php
354+
HtmlErrorRenderer::setTemplate($this->getProjectDir().'/templates/error.html');
355+
356+
.. note::
357+
358+
While these approaches might not cover every edge case, they provide additional customization options beyond the default error templates or error controller overrides.

0 commit comments

Comments
 (0)