diff --git a/homeassistant/components/radio_browser/__init__.py b/homeassistant/components/radio_browser/__init__.py index 92be0527e70d..c1167090fb44 100644 --- a/homeassistant/components/radio_browser/__init__.py +++ b/homeassistant/components/radio_browser/__init__.py @@ -1,6 +1,5 @@ """The Radio Browser integration.""" -from aiodns.error import DNSError from radios import RadioBrowser, RadioBrowserError from homeassistant.config_entries import ConfigEntry @@ -25,7 +24,7 @@ async def async_setup_entry( try: await radios.stats() - except (DNSError, RadioBrowserError) as err: + except RadioBrowserError as err: raise ConfigEntryNotReady("Could not connect to Radio Browser API") from err entry.runtime_data = radios diff --git a/homeassistant/components/radio_browser/media_source.py b/homeassistant/components/radio_browser/media_source.py index 6d8545314c7c..125b04658954 100644 --- a/homeassistant/components/radio_browser/media_source.py +++ b/homeassistant/components/radio_browser/media_source.py @@ -3,7 +3,6 @@ import mimetypes from typing import override -from aiodns.error import DNSError import pycountry from radios import FilterBy, Order, RadioBrowser, RadioBrowserError, Station @@ -74,7 +73,7 @@ class RadioMediaSource(MediaSource): radios = self.radios try: station = await radios.station(uuid=item.identifier) - except (DNSError, RadioBrowserError) as e: + except RadioBrowserError as e: raise Unresolvable( translation_domain=DOMAIN, translation_key="radio_browser_error", @@ -129,7 +128,7 @@ class RadioMediaSource(MediaSource): *await self._async_build_by_country(radios, item), ], ) - except (DNSError, RadioBrowserError) as e: + except RadioBrowserError as e: raise BrowseError( translation_domain=DOMAIN, translation_key="radio_browser_error", @@ -162,7 +161,7 @@ class RadioMediaSource(MediaSource): ), ) ) - except (DNSError, RadioBrowserError) as e: + except RadioBrowserError as e: raise BrowseError( translation_domain=DOMAIN, translation_key="radio_browser_error", diff --git a/tests/components/radio_browser/test_media_source.py b/tests/components/radio_browser/test_media_source.py index fa5f440137ce..a58d7c797dfc 100644 --- a/tests/components/radio_browser/test_media_source.py +++ b/tests/components/radio_browser/test_media_source.py @@ -3,9 +3,8 @@ from types import SimpleNamespace from unittest.mock import AsyncMock, MagicMock, patch -from aiodns.error import DNSError import pytest -from radios import FilterBy, Order, RadioBrowserError +from radios import FilterBy, Order, RadioBrowserConnectionError, RadioBrowserError from homeassistant.components import media_source from homeassistant.components.media_player import BrowseError, SearchMediaQuery @@ -83,7 +82,7 @@ async def test_browsing_local( @pytest.mark.parametrize( "exception", - [DNSError, RadioBrowserError], + [RadioBrowserConnectionError, RadioBrowserError], ) async def test_browsing_exceptions( hass: HomeAssistant, @@ -161,7 +160,7 @@ async def test_search_media( @pytest.mark.parametrize( "exception", - [DNSError, RadioBrowserError], + [RadioBrowserConnectionError, RadioBrowserError], ) async def test_search_media_exceptions( hass: HomeAssistant, @@ -213,7 +212,7 @@ async def test_search_media_not_ready( @pytest.mark.parametrize( "exception", - [DNSError, RadioBrowserError], + [RadioBrowserConnectionError, RadioBrowserError], ) async def test_resolve_media_exceptions( hass: HomeAssistant,