Fix BadNameAPIError to include the expected name (#514)

This commit is contained in:
J. Nick Koston 2023-07-27 08:37:31 -05:00 committed by GitHub
parent b9ec1d0bc5
commit 8acefd1d05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -383,13 +383,17 @@ class APIConnection:
raise APIConnectionError("Incompatible API version.")
self.api_version = api_version
expected_name = self._params.expected_name
received_name = resp.name
if (
self._params.expected_name is not None
and resp.name != ""
and resp.name != self._params.expected_name
expected_name is not None
and received_name != ""
and received_name != expected_name
):
raise BadNameAPIError(
f"Server sent a different name '{resp.name}'", resp.name
f"Expected '{expected_name}' but server sent "
f"a different name: '{received_name}'",
received_name,
)
def _async_schedule_keep_alive(self) -> None: