Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pychromecast/dial.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import zeroconf

from .const import CAST_TYPE_AUDIO, CAST_TYPE_CHROMECAST, CAST_TYPE_GROUP
from .error import ZeroConfInstanceRequired
from .error import ZeroConfInstanceRequired, ResolveHostFailed
from .models import ZEROCONF_ERRORS, CastInfo, HostServiceInfo, MDNSServiceInfo

XML_NS_UPNP_DEVICE = "{urn:schemas-upnp-org:device-1-0}"
Expand Down Expand Up @@ -112,6 +112,8 @@ def _get_status(
if host:
_LOGGER.debug("Resolved service %s to %s", service, host)
break
else:
raise ResolveHostFailed("Unable to find host to read status from.")

if secure:
url = FORMAT_BASE_URL_HTTPS.format(host) + path
Expand Down Expand Up @@ -175,6 +177,7 @@ def get_cast_type(
urllib.error.URLError,
OSError,
ValueError,
ResolveHostFailed,
) as err:
_LOGGER.warning(
"Failed to determine cast type for host %s (%s) (services:%s)",
Expand Down
4 changes: 4 additions & 0 deletions pychromecast/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,9 @@ def __init__(self, request: str, timeout: float) -> None:
super().__init__(self.MSG.format(request=request, timeout=timeout))


class ResolveHostFailed(PyChromecastError):
"""Raised when library is unable to resolve a name into an connectable address."""


class ZeroConfInstanceRequired(PyChromecastError):
"""Raised when a zeroconf instance is required."""