split message and apply to more scenarios

This commit is contained in:
David Kennedy 2025-03-26 18:32:59 -04:00
parent 7a935d11fc
commit 72f256e0b8
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
2 changed files with 6 additions and 8 deletions

View file

@ -174,6 +174,8 @@ class EPPLibWrapper:
try:
return self._send(command)
except RegistryError as err:
if err.response:
logger.info(f"cltrid is {err.response.cl_tr_id} svtrid is {err.response.sv_tr_id}")
if (
err.is_transport_error()
or err.is_connection_error()
@ -182,12 +184,7 @@ class EPPLibWrapper:
or err.should_retry()
):
message = f"{cmd_type} failed and will be retried"
info_message = f"{message} Error: {err}"
if err.response:
info_message = (
f"{info_message}| cltrid is {err.response.cl_tr_id} svtrid is {err.response.sv_tr_id}"
)
logger.info(f"{info_message}")
logger.info(f"{message} Error: {err}")
return self._retry(command)
else:
raise err

View file

@ -311,9 +311,10 @@ class TestClient(TestCase):
# send() is called 5 times: send(login), send(command) fail, send(logout), send(login), send(command)
self.assertEquals(mock_send.call_count, 5)
# Assertion proper logging; note that the
mock_logger.info.assert_called_once_with(
"InfoDomainCommand failed and will be retried Error: Registrar is not logged in.| cltrid is cl_tr_id svtrid is sv_tr_id"
mock_logger.info.assert_any_call(
"InfoDomainCommand failed and will be retried Error: Registrar is not logged in."
)
mock_logger.info.assert_any_call("cltrid is cl_tr_id svtrid is sv_tr_id")
@less_console_noise_decorator
def fake_failure_send_concurrent_threads(self, command=None, cleaned=None):