mirror of
https://github.com/home-assistant/core.git
synced 2025-04-27 02:37:50 +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:
|
except anthropic.APIConnectionError:
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except anthropic.APIStatusError as e:
|
except anthropic.APIStatusError as e:
|
||||||
if isinstance(e.body, dict):
|
errors["base"] = "unknown"
|
||||||
errors["base"] = e.body.get("error", {}).get("type", "unknown")
|
if (
|
||||||
else:
|
isinstance(e.body, dict)
|
||||||
errors["base"] = "unknown"
|
and (error := e.body.get("error"))
|
||||||
|
and error.get("type") == "authentication_error"
|
||||||
|
):
|
||||||
|
errors["base"] = "authentication_error"
|
||||||
except Exception:
|
except Exception:
|
||||||
_LOGGER.exception("Unexpected exception")
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
|
@ -108,7 +108,7 @@ async def test_options(
|
|||||||
),
|
),
|
||||||
body={"type": "error", "error": {"type": "invalid_request_error"}},
|
body={"type": "error", "error": {"type": "invalid_request_error"}},
|
||||||
),
|
),
|
||||||
"invalid_request_error",
|
"unknown",
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
AuthenticationError(
|
AuthenticationError(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user