Skip to content

Commit

Permalink
Follow up comment
Browse files Browse the repository at this point in the history
  • Loading branch information
jbouwh committed Nov 2, 2023
1 parent 63efeca commit 496b83e
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/websocket_api/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ async def handle_call_service(
connection.logger.debug("", exc_info=err)
connection.send_error(
msg["id"],
const.ERR_HOME_ASSISTANT_ERROR,
const.ERR_SERVICE_VALIDATION_ERROR,
f"Validation error: {err}",
translation_domain=err.translation_domain,
translation_key=err.translation_key,
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/websocket_api/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
ERR_NOT_FOUND: Final = "not_found"
ERR_NOT_SUPPORTED: Final = "not_supported"
ERR_HOME_ASSISTANT_ERROR: Final = "home_assistant_error"
ERR_SERVICE_VALIDATION_ERROR: Final = "service_validation_error"
ERR_UNKNOWN_COMMAND: Final = "unknown_command"
ERR_UNKNOWN_ERROR: Final = "unknown_error"
ERR_UNAUTHORIZED: Final = "unauthorized"
Expand Down
2 changes: 0 additions & 2 deletions homeassistant/components/websocket_api/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ def error_message(
"code": code,
"message": message,
}
# In case a ServiceNotFound error is raised
# we use 'websocket_api' as default translation_domain.
# In case `translation_key` is `None` we do not set it, nor the
# `translation`_placeholders` and `translation_domain`.
if translation_key is not None:
Expand Down
2 changes: 1 addition & 1 deletion tests/components/websocket_api/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ async def unknown_error_call(_):
assert msg["id"] == 6
assert msg["type"] == const.TYPE_RESULT
assert msg["success"] is False
assert msg["error"]["code"] == "home_assistant_error"
assert msg["error"]["code"] == "service_validation_error"
assert msg["error"]["message"] == "Validation error: error_message"
assert msg["error"]["translation_placeholders"] == {"option": "bla"}
assert msg["error"]["translation_key"] == "custom_error"
Expand Down

0 comments on commit 496b83e

Please sign in to comment.