Contao\CoreBundle\EventListener\ExceptionConverterListener::convertToHttpException PHP Method

convertToHttpException() private method

Converts an exception to an HTTP exception.
private convertToHttpException ( Exception $exception, string $target ) : Symfony\Component\HttpKernel\Exception\HttpException | null
$exception Exception
$target string
return Symfony\Component\HttpKernel\Exception\HttpException | null
    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;
    }