public function onKernelException(GetResponseForExceptionEvent $event)
{
$exception = $event->getException();
if ($exception instanceof NotFoundException) {
$event->setException(new NotFoundHttpException($this->getTranslatedMessage($exception), $exception));
} elseif ($exception instanceof UnauthorizedException) {
$event->setException(new AccessDeniedException($this->getTranslatedMessage($exception), $exception));
} elseif ($exception instanceof BadStateException || $exception instanceof InvalidArgumentException) {
$event->setException(new BadRequestHttpException($this->getTranslatedMessage($exception), $exception));
} elseif ($exception instanceof Translatable) {
$event->setException(new HttpException(Response::HTTP_INTERNAL_SERVER_ERROR, get_class($exception) . ': ' . $this->getTranslatedMessage($exception), $exception));
}
}