protected function handleException(Exception $exception, Request $request, $type)
{
if ($this->errorHandler === null) {
throw $exception;
}
if ($this->eventDispatcher !== null) {
$event = new GetResponseForExceptionEvent($this, $request, $type, $exception);
$this->eventDispatcher->dispatch(KernelEvents::EXCEPTION, $event);
$response = $event->getResponse() ?: $this->errorHandler->handle($exception);
} else {
$response = $this->errorHandler->handle($exception);
}
try {
return $this->filterResponse($response, $request, $type);
} catch (Exception $e) {
return $response;
}
}