Skip to content

Commit d62ece4

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

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

controller/error_pages.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,3 +336,25 @@ 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+
341+
Particular Error Scenarios
342+
------------------------------------
343+
344+
There are a multitude of error scenarios when customising error pages. Here are a few of them:
345+
346+
### PHP Errors
347+
348+
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.yml 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>`).
349+
350+
### Errors Before Twig Initialization
351+
352+
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:
353+
354+
```php
355+
HtmlErrorRenderer::setTemplate($this->getProjectDir().'/templates/error.html');
356+
357+
358+
.. note::
359+
360+
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)