handling of OBJECT_EXISTS in nameserver create_host and update_host methods

This commit is contained in:
David Kennedy 2023-10-31 10:42:42 -04:00
parent 918c5ef0b2
commit 662bb1a1ef
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B

View file

@ -277,7 +277,12 @@ class Domain(TimeStampedModel, DomainHelper):
return response.code
except RegistryError as e:
logger.error("Error _create_host, code was %s error was %s" % (e.code, e))
raise e
# OBJECT_EXISTS is an expected error code that should not raise
# an exception, rather return the code to be handled separately
if response and response.code == ErrorCode.OBJECT_EXISTS:
return response.code
else:
raise e
def _convert_list_to_dict(self, listToConvert: list[tuple[str, list]]):
"""converts a list of hosts into a dictionary
@ -1625,7 +1630,12 @@ class Domain(TimeStampedModel, DomainHelper):
return response.code
except RegistryError as e:
logger.error("Error _update_host, code was %s error was %s" % (e.code, e))
raise e
# OBJECT_EXISTS is an expected error code that should not raise
# an exception, rather return the code to be handled separately
if response and response.code == ErrorCode.OBJECT_EXISTS:
return response.code
else:
raise e
def addAndRemoveHostsFromDomain(
self, hostsToAdd: list[str], hostsToDelete: list[str]