mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 10:17:51 +00:00
Avoid unknown error translation strings in anthropic (#127823)
This commit is contained in:
parent
4d003f51c3
commit
d8b51b4f2c
@ -87,10 +87,13 @@ class AnthropicConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
except anthropic.APIConnectionError:
|
||||
errors["base"] = "cannot_connect"
|
||||
except anthropic.APIStatusError as e:
|
||||
if isinstance(e.body, dict):
|
||||
errors["base"] = e.body.get("error", {}).get("type", "unknown")
|
||||
else:
|
||||
errors["base"] = "unknown"
|
||||
errors["base"] = "unknown"
|
||||
if (
|
||||
isinstance(e.body, dict)
|
||||
and (error := e.body.get("error"))
|
||||
and error.get("type") == "authentication_error"
|
||||
):
|
||||
errors["base"] = "authentication_error"
|
||||
except Exception:
|
||||
_LOGGER.exception("Unexpected exception")
|
||||
errors["base"] = "unknown"
|
||||
|
@ -108,7 +108,7 @@ async def test_options(
|
||||
),
|
||||
body={"type": "error", "error": {"type": "invalid_request_error"}},
|
||||
),
|
||||
"invalid_request_error",
|
||||
"unknown",
|
||||
),
|
||||
(
|
||||
AuthenticationError(
|
||||
|
Loading…
x
Reference in New Issue
Block a user