private function getUrlAdapter(UriInterface $url)
    {
        $embedFactory = $this->embedFactory;
        $url = Url::create((string) $url);

        try {
            $adapter = $embedFactory($url);
        } catch (InvalidUrlException $e) {
            throw new EmbedResolverException($e->getMessage(), 1, $e);
        } catch (EmbedException $e) {
            throw new EmbedResolverException('Provider exception occurred', 2, $e);
        }

        return $adapter;
    }