Add ServiceValidationError and translation support (#102592)
* Add ServiceValidationError * Add translation support * Extend translation support to HomeAssistantError * Add translation support for ServiceNotFound exc * Frontend translation & translation_key from caller * Improve fallback message * Set websocket_api as default translation_domain * Add MQTT ServiceValidationError exception * Follow up comments * Revert removing gueard on translation_key * Revert test changes to fix CI test * Follow up comments * Fix CI test * Follow up * Improve language * Follow up comment
This commit is contained in:
parent
5cd61a0cf4
commit
54cf7010cd
12 changed files with 206 additions and 18 deletions
|
@ -134,9 +134,26 @@ class ActiveConnection:
|
|||
self.send_message(messages.event_message(msg_id, event))
|
||||
|
||||
@callback
|
||||
def send_error(self, msg_id: int, code: str, message: str) -> None:
|
||||
"""Send a error message."""
|
||||
self.send_message(messages.error_message(msg_id, code, message))
|
||||
def send_error(
|
||||
self,
|
||||
msg_id: int,
|
||||
code: str,
|
||||
message: str,
|
||||
translation_key: str | None = None,
|
||||
translation_domain: str | None = None,
|
||||
translation_placeholders: dict[str, Any] | None = None,
|
||||
) -> None:
|
||||
"""Send an error message."""
|
||||
self.send_message(
|
||||
messages.error_message(
|
||||
msg_id,
|
||||
code,
|
||||
message,
|
||||
translation_key=translation_key,
|
||||
translation_domain=translation_domain,
|
||||
translation_placeholders=translation_placeholders,
|
||||
)
|
||||
)
|
||||
|
||||
@callback
|
||||
def async_handle_binary(self, handler_id: int, payload: bytes) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue