mirror of
https://github.com/home-assistant/core.git
synced 2026-12-04 12:50:45 -04:00
Translate invalid API token error in telegram_bot (#184442)
This commit is contained in:
@@ -166,8 +166,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: TelegramBotConfigEntry)
|
||||
try:
|
||||
await bot.get_me()
|
||||
except InvalidToken as err:
|
||||
# pylint: disable-next=home-assistant-exception-not-translated
|
||||
raise ConfigEntryAuthFailed("Invalid API token for Telegram Bot.") from err
|
||||
raise ConfigEntryAuthFailed(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="invalid_api_key",
|
||||
) from err
|
||||
except TelegramError as err:
|
||||
# Do not let the message through: the Telegram API URL embeds the bot
|
||||
# token, and library errors quote that URL.
|
||||
|
||||
@@ -198,6 +198,9 @@
|
||||
"failed_to_load_url": {
|
||||
"message": "Failed to load URL: {error}"
|
||||
},
|
||||
"invalid_api_key": {
|
||||
"message": "The Telegram bot API token is invalid."
|
||||
},
|
||||
"invalid_chat_ids": {
|
||||
"message": "Invalid chat IDs: {chat_ids}. Please configure the chat IDs for {bot_name}."
|
||||
},
|
||||
|
||||
@@ -1476,6 +1476,7 @@ async def test_async_setup_entry_failed(
|
||||
|
||||
await hass.async_block_till_done()
|
||||
assert mock_broadcast_config_entry.state is ConfigEntryState.SETUP_ERROR
|
||||
assert mock_broadcast_config_entry.error_reason_translation_key == "invalid_api_key"
|
||||
|
||||
|
||||
async def test_answer_callback_query(
|
||||
|
||||
Reference in New Issue
Block a user