Skip to content

Using ErrorController do not give serialized exceptions for all exception types #45478

Closed
@Guuzen

Description

@Guuzen

Symfony version(s) affected

5.4.4

Description

I want all of my exceptions to be serialized and there is SerializerErrorRenderer for this. But Symfony\Component\ErrorHandler\ErrorHandler overrides this behaviour and return errors rendered as html in case of, for example, type errors.
There is 2 hardcoded exception renderers in ErrorHandler - CliErrorRenderer and HtmlErrorRenderer but no SerializerErrorRenderer.

In general there is 2 places where user should decide how to render errors - ErrorController dependency and ErrorHandler exception handler - is this a problem?

How to reproduce

throw new \RuntimeException();
in controller will return serialized exception.

but

$foo = [];
$bar = $foo[new \stdClass];

in controller will return rendered as html exception.

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions