Fix incorrect exception in telegram_bot (#162191)

This commit is contained in:
epenet
2026-02-04 13:32:29 +01:00
committed by GitHub
parent 9eeae8eac6
commit 668995da73
2 changed files with 2 additions and 3 deletions

View File

@@ -14,7 +14,6 @@ from telegram.ext import Application, ApplicationBuilder, TypeHandler
from homeassistant.components.http import HomeAssistantRequest, HomeAssistantView
from homeassistant.const import CONF_URL
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.network import get_url
from .bot import BaseTelegramBot, TelegramBotConfigEntry
@@ -42,7 +41,7 @@ async def async_setup_bot_platform(
webhook_registered = await pushbot.register_webhook()
if not webhook_registered:
raise ConfigEntryNotReady("Failed to register webhook with Telegram")
raise RuntimeError("Failed to register webhook with Telegram")
_LOGGER.info(
"[%s %s] Webhook registered with %s",
bot.username,

View File

@@ -41,7 +41,7 @@ async def test_set_webhooks_failed(
# first fail with exception, second fail with False
assert mock_set_webhook.call_count == 2
# SETUP_ERROR is result of ConfigEntryNotReady("Failed to register webhook with Telegram") in webhooks.py
# SETUP_ERROR is result of RuntimeError("Failed to register webhook with Telegram") in webhooks.py
assert mock_webhooks_config_entry.state is ConfigEntryState.SETUP_ERROR
# test fail after retries