Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

add Particular Error Scenarios #19468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 7.1
Choose a base branch
Loading
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions 21 controller/error_pages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,24 @@ time and again, you can have just one (or several) listeners deal with them.
your application (like :class:`Symfony\\Component\\Security\\Core\\Exception\\AccessDeniedException`)
and takes measures like redirecting the user to the login page, logging them
out and other things.

Particular Error Scenarios
--------------------------

There are a multitude of error scenarios when customising error pages. Here are a few of them:

### PHP Errors

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>`).

### Errors Before Twig Initialization

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:

```php
HtmlErrorRenderer::setTemplate($this->getProjectDir().'/templates/error.html');

.. note::

While these approaches might not cover every edge case,
they provide additional customization options beyond the default error templates or error controller overrides.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.