Make class function for GenericError mapping

This commit is contained in:
Erin 2023-12-01 10:10:25 -08:00
parent c3a23c23fa
commit 578f5bac1a
No known key found for this signature in database
GPG key ID: 1CAD275313C62460
2 changed files with 5 additions and 1 deletions

View file

@ -31,7 +31,7 @@ DOMAIN_API_MESSAGES = {
), ),
"invalid": "Enter a domain using only letters, numbers, or hyphens (though we don't recommend using hyphens).", "invalid": "Enter a domain using only letters, numbers, or hyphens (though we don't recommend using hyphens).",
"success": "That domain is available!", "success": "That domain is available!",
"error": GenericError._error_mapping[GenericErrorCodes.CANNOT_CONTACT_REGISTRY], "error": GenericError.get_error_mapping(GenericErrorCodes.CANNOT_CONTACT_REGISTRY),
} }

View file

@ -60,6 +60,10 @@ contact help@get.gov.
def __str__(self): def __str__(self):
return f"{self.message}" return f"{self.message}"
@classmethod
def get_error_mapping(self, code=None):
return self._error_mapping.get(code)
class NameserverErrorCodes(IntEnum): class NameserverErrorCodes(IntEnum):
"""Used in the NameserverError class for """Used in the NameserverError class for