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

Document the handling of exceptions with listeners #4181

Closed
Labels
StalledactionableClear and specific issues ready for anyone to take them.
@stof

Description

@stof

Currently, the doc explains how to overwrite the error page rendered by the controller.
This is fine for apps wanting to make the error page look better by having them consistent with their styles.

However, the exception handling system of Symfony is much more flexible than that. This can be particularly useful if you throw domain-related exceptions in your codebase which should be rendered as client errors rather than a 500 page for instance.
The usage of listeners on thekernel.exception event allows to handle this case very easily, and without requiring to use subrequests and a controller. Seesymfony/symfony#11752 (comment) for the original discussion.
As a side note, this is exactly what the Security component does in core for theSymfony\Component\Security\Core\Exception\AccessDeniedException.

I don't know a public project using this approach (but I'm very far from knowing the codebase all open-source projects based on Symfony). However@weaverryan, I know that KnpLabs used this approach already in one of its project for which I saw the codebase when I was working there. So some of your colleagues should be able to show you this approach at least.

Metadata

Metadata

Assignees

No one assigned

    Labels

    StalledactionableClear and specific issues ready for anyone to take them.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp