symfony exception listener sending headers

380 Views Asked by At

I've created an exceptionListener which is catches exceptions. It's registered:

  App\Listener\ExceptionListener:
    tags:
      - { name: kernel.event_listener, event: kernel.exception, method: onKernelException }

also got the logic to handle throwables as well. In this example, i'd like to create a simple redirectionResponse:

$event->setResponse(new RedirectResponse('/error.html', 302, []));

ofc the /error.html is available, I've ran from the URL bar.

And yet if I catching the exception, after the redirection, I see app.CRITICAL log entry right after the redirection URL:

app.CRITICAL: Failed to start the session because headers have already been sent by "/home/PROJECT/vendor/symfony/http-foundation/Response.php" at line 368.

so the error log refers to the response that I've set up for $event->setResponse(...) however I didn't touch any header specific events e.g. header() setCookie(), etc.

Is there any way to trace back where the first header was sent?

0

There are 0 best solutions below