diff --git a/src/api/views.py b/src/api/views.py index f84f4439f..10507fd7f 100644 --- a/src/api/views.py +++ b/src/api/views.py @@ -31,7 +31,7 @@ DOMAIN_API_MESSAGES = { ), "invalid": "Enter a domain using only letters, numbers, or hyphens (though we don't recommend using hyphens).", "success": "That domain is available!", - "error": GenericError._error_mapping[GenericErrorCodes.CANNOT_CONTACT_REGISTRY], + "error": GenericError.get_error_mapping(GenericErrorCodes.CANNOT_CONTACT_REGISTRY), } diff --git a/src/registrar/utility/errors.py b/src/registrar/utility/errors.py index 93b8855f3..7edf11deb 100644 --- a/src/registrar/utility/errors.py +++ b/src/registrar/utility/errors.py @@ -60,6 +60,10 @@ contact help@get.gov. def __str__(self): return f"{self.message}" + @classmethod + def get_error_mapping(self, code=None): + return self._error_mapping.get(code) + class NameserverErrorCodes(IntEnum): """Used in the NameserverError class for