Repository: home-assistant/core
File: homeassistant/helpers/update_coordinator.py (Python)

Code before:
                log_failures=False,
                raise_on_auth_failed=True,
                raise_on_entry_error=True,
            )
            if self.last_update_success:
                return
        ex = ConfigEntryNotReady()
        ex.__cause__ = self.last_exception
        raise ex

    async def __wrap_async_setup(self) -> bool:
        """Error handling for _async_setup."""
        try:
            await self._async_setup()

        except (
            OAuth2TokenRequestReauthError,
            OAuth2TokenRequestTransientError,
            OAuth2TokenRequestError,
        ) as err:
            if isinstance(err, OAuth2TokenRequestReauthError):
                self.last_exception = err
                self.last_update_success = False
                # Non-recoverable error
                raise ConfigEntryAuthFailed from err
            raise

        except (
            TimeoutError,
            requests.exceptions.Timeout,
            aiohttp.ClientError,
            requests.exceptions.RequestException,
            urllib.error.URLError,
            UpdateFailed,
        ) as err:
            self.last_exception = err

        except (ConfigEntryError, ConfigEntryAuthFailed) as err:
            self.last_exception = err
            self.last_update_success = False
            raise

        except Exception as err:  # pylint: disable=broad-except
            self.last_exception = err
            self.logger.exception("Unexpected error fetching %s data", self.name)
        else:
            return True

        self.last_update_success = False
        return False


Review comment (suggestion):
I don't think we should raise in this case, line 369. We should just `pass` since that will set `last_update_success` to `False` and this will cause `ConfigEntryNotReady` to be raised.

Please add a test for these cases.

Code after:
                raise_on_auth_failed=True,
                raise_on_entry_error=True,
            )
            if self.last_update_success:
                return
        ex = ConfigEntryNotReady()
        ex.__cause__ = self.last_exception
        raise ex

    async def __wrap_async_setup(self) -> bool:
        """Error handling for _async_setup."""
        try:
            await self._async_setup()

        except OAuth2TokenRequestError as err:
            self.last_exception = err
            if isinstance(err, OAuth2TokenRequestReauthError):
                self.last_update_success = False
                # Non-recoverable error
                raise ConfigEntryAuthFailed from err

        except (
            TimeoutError,
            requests.exceptions.Timeout,
            aiohttp.ClientError,
            requests.exceptions.RequestException,
            urllib.error.URLError,
            UpdateFailed,
        ) as err:
            self.last_exception = err

        except (ConfigEntryError, ConfigEntryAuthFailed) as err:
            self.last_exception = err
            self.last_update_success = False
            raise

        except Exception as err:  # pylint: disable=broad-except
            self.last_exception = err
            self.logger.exception("Unexpected error fetching %s data", self.name)
        else:
            return True

        self.last_update_success = False
        return False

    async def _async_setup(self) -> None:
        """Set up the coordinator.

        Can be overwritten by integrations to load data or resources
        only once during the first refresh.
        """