mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-03 00:12:16 +02:00
wip
This commit is contained in:
parent
b4b6565f81
commit
d31af94a15
2 changed files with 13 additions and 6 deletions
|
@ -100,7 +100,7 @@ class EPPLibWrapper:
|
|||
response = self._client.send(self._login) # type: ignore
|
||||
if response.code >= 2000: # type: ignore
|
||||
self._client.close() # type: ignore
|
||||
raise LoginError(response.msg) # type: ignore
|
||||
raise LoginError(response.msg, response=response) # type: ignore
|
||||
|
||||
def _disconnect(self) -> None:
|
||||
"""Close the connection. Sends a logout command and closes the connection."""
|
||||
|
@ -144,14 +144,14 @@ class EPPLibWrapper:
|
|||
text = "failed to execute due to a registry login error."
|
||||
message = f"{cmd_type} {text}"
|
||||
logger.error(f"{message} Error: {err}")
|
||||
raise RegistryError(message) from err
|
||||
raise LoginError(message, response=err.response) from err
|
||||
except Exception as err:
|
||||
message = f"{cmd_type} failed to execute due to an unknown error."
|
||||
logger.error(f"{message} Error: {err}")
|
||||
raise RegistryError(message) from err
|
||||
else:
|
||||
if response.code >= 2000:
|
||||
raise RegistryError(response.msg, code=response.code)
|
||||
raise RegistryError(response.msg, code=response.code, response=response)
|
||||
else:
|
||||
return response
|
||||
|
||||
|
@ -182,7 +182,10 @@ class EPPLibWrapper:
|
|||
or err.should_retry()
|
||||
):
|
||||
message = f"{cmd_type} failed and will be retried"
|
||||
logger.info(f"{message} Error: {err}")
|
||||
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}")
|
||||
return self._retry(command)
|
||||
else:
|
||||
raise err
|
||||
|
|
|
@ -62,14 +62,18 @@ class RegistryError(Exception):
|
|||
- 2501 - 2502 Something malicious or abusive may have occurred
|
||||
"""
|
||||
|
||||
def __init__(self, *args, code=None, note="", **kwargs):
|
||||
def __init__(self, *args, code=None, note="", response=None, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.code = code
|
||||
self.response = response
|
||||
# note is a string that can be used to provide additional context
|
||||
self.note = note
|
||||
|
||||
|
||||
def should_retry(self):
|
||||
return self.code == ErrorCode.COMMAND_FAILED
|
||||
# COMMAND_USE_ERROR is returning with message, Registrar is not logged in,
|
||||
# which can be recovered from with a retry
|
||||
return self.code == ErrorCode.COMMAND_FAILED or self.code == ErrorCode.COMMAND_USE_ERROR
|
||||
|
||||
def is_transport_error(self):
|
||||
return self.code == ErrorCode.TRANSPORT_ERROR
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue