Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
dylan-b-efficience-it wants to merge1 commit intosymfony:7.1
base:7.1
Choose a base branch
Loading
fromdylan-b-efficience-it:docs/particular-error-scenarios
Open
Changes fromall 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 deletionscontroller/error_pages.rst
View file
Open in desktop
Original file line numberDiff line numberDiff 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.

[8]ページ先頭

©2009-2025 Movatter.jp