/**
* Publishes the finish request event, then pop the request from the stack.
*
* Note that the order of the operations is important here, otherwise
* operations such as {@link RequestStack::getParentRequest()} can lead to
* weird results.
*/
private function finishRequest(Request
$request, int
$type): void
{ $this->dispatcher->
dispatch(new FinishRequestEvent($this,
$request,
$type), KernelEvents::FINISH_REQUEST
);
} /**
* Handles a throwable by trying to convert it to a Response.
*/
private function handleThrowable(\Throwable
$e, Request
$request, int
$type): Response
{ $event =
new ExceptionEvent($this,
$request,
$type,
$e);
$this->dispatcher->
dispatch($event, KernelEvents::EXCEPTION
);
// a listener might have replaced the exception