private function convertToHttpException(\Exception $exception, $target)
{
switch ($target) {
case 'AccessDeniedHttpException':
return new AccessDeniedHttpException($exception->getMessage(), $exception);
case 'InternalServerErrorHttpException':
return new InternalServerErrorHttpException($exception->getMessage(), $exception);
case 'NotFoundHttpException':
return new NotFoundHttpException($exception->getMessage(), $exception);
case 'ServiceUnavailableHttpException':
return new ServiceUnavailableHttpException(null, $exception->getMessage(), $exception);
}
return null;
}