From 4f3deae19852d917f97a0d8e3919949a800557fa Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Wed, 29 Nov 2023 15:37:30 -0800 Subject: [PATCH 01/19] Add error message when epp domain check fails --- src/api/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/api/views.py b/src/api/views.py index 2cb23a9b2..8cc2eda0c 100644 --- a/src/api/views.py +++ b/src/api/views.py @@ -22,7 +22,8 @@ DOMAIN_API_MESSAGES = { " Contact us if you need help coming up with a domain.", "invalid": "Enter a domain using only letters, numbers, or hyphens (though we don't recommend using hyphens).", "success": "That domain is available!", - "error": "Error finding domain availability.", + "error": "Error finding domain availability. Please wait a few minutes and try again. If you continue \ + to receive this error after a few tries, contact help@get.gov", } @@ -64,8 +65,8 @@ def check_domain_available(domain): else: # domain search string doesn't end with .gov, add it on here return Domain.available(domain + ".gov") - except Exception: - return False + except Exception as err: + return err @require_http_methods(["GET"]) From a956bef03795ad4ed79935d498a5c86ac470c18c Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Wed, 29 Nov 2023 15:48:23 -0800 Subject: [PATCH 02/19] Update error handling test --- src/api/tests/test_available.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/tests/test_available.py b/src/api/tests/test_available.py index 524fd689a..a80290985 100644 --- a/src/api/tests/test_available.py +++ b/src/api/tests/test_available.py @@ -109,7 +109,7 @@ class AvailableViewTest(MockEppLib): self.assertFalse(json.loads(response.content)["available"]) # domain set to raise error returns false for availability error_domain_available = available(request, "errordomain.gov") - self.assertFalse(json.loads(error_domain_available.content)["available"]) + self.assertRaises(json.loads(error_domain_available.content)["available"]) class AvailableAPITest(MockEppLib): From 18ae412d0e87e0916448a694ffacee7cb18fd882 Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Wed, 29 Nov 2023 16:39:03 -0800 Subject: [PATCH 03/19] Update availability tests --- src/api/tests/test_available.py | 10 ++++++---- src/api/views.py | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/api/tests/test_available.py b/src/api/tests/test_available.py index a80290985..dc0f5ee54 100644 --- a/src/api/tests/test_available.py +++ b/src/api/tests/test_available.py @@ -101,15 +101,17 @@ class AvailableViewTest(MockEppLib): self.assertTrue(json.loads(response.content)["available"]) def test_error_handling(self): - """Calling with bad strings raises an error.""" + """Calling with bad strings returns error (error verifying) or unavailable (invalid domain).""" bad_string = "blah!;" request = self.factory.get(API_BASE_PATH + bad_string) request.user = self.user response = available(request, domain=bad_string) self.assertFalse(json.loads(response.content)["available"]) - # domain set to raise error returns false for availability - error_domain_available = available(request, "errordomain.gov") - self.assertRaises(json.loads(error_domain_available.content)["available"]) + # domain set to raise error returns false for availability and error message + error_domain_response = available(request, domain="errordomain.gov") + self.assertFalse(json.loads(error_domain_response.content)["available"]) + self.assertIn("Error finding domain availability", + json.loads(error_domain_response.content)["message"]) class AvailableAPITest(MockEppLib): diff --git a/src/api/views.py b/src/api/views.py index 56a2b786a..d01acaa3f 100644 --- a/src/api/views.py +++ b/src/api/views.py @@ -30,8 +30,8 @@ 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": "Error finding domain availability. Please wait a few minutes and try again. If you continue \ - to receive this error after a few tries, contact help@get.gov", + "error": "Error finding domain availability. Please wait a few minutes and try again.\ + If you continue to receive this error after a few tries, contact help@get.gov", } @@ -74,7 +74,7 @@ def check_domain_available(domain): # domain search string doesn't end with .gov, add it on here return Domain.available(domain + ".gov") except Exception as err: - return err + raise err @require_http_methods(["GET"]) From b3145b96c72999d7e18a90cc493628e5a3897351 Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Wed, 29 Nov 2023 16:58:00 -0800 Subject: [PATCH 04/19] Fix lint errors --- src/api/tests/test_available.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/api/tests/test_available.py b/src/api/tests/test_available.py index dc0f5ee54..412dae64b 100644 --- a/src/api/tests/test_available.py +++ b/src/api/tests/test_available.py @@ -110,8 +110,7 @@ class AvailableViewTest(MockEppLib): # domain set to raise error returns false for availability and error message error_domain_response = available(request, domain="errordomain.gov") self.assertFalse(json.loads(error_domain_response.content)["available"]) - self.assertIn("Error finding domain availability", - json.loads(error_domain_response.content)["message"]) + self.assertIn("Error finding domain availability", json.loads(error_domain_response.content)["message"]) class AvailableAPITest(MockEppLib): From a5e2e030c253f3fdd2c29c7f7d7f1ebb2daa4718 Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Thu, 30 Nov 2023 11:10:50 -0800 Subject: [PATCH 05/19] Separated availability error tests into two --- src/api/tests/test_available.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/api/tests/test_available.py b/src/api/tests/test_available.py index 412dae64b..2bd6c70a6 100644 --- a/src/api/tests/test_available.py +++ b/src/api/tests/test_available.py @@ -100,19 +100,23 @@ class AvailableViewTest(MockEppLib): response = available(request, domain="igorville") self.assertTrue(json.loads(response.content)["available"]) - def test_error_handling(self): - """Calling with bad strings returns error (error verifying) or unavailable (invalid domain).""" + def test_bad_string_handling(self): + """Calling with bad strings returns unavailable.""" bad_string = "blah!;" request = self.factory.get(API_BASE_PATH + bad_string) request.user = self.user response = available(request, domain=bad_string) self.assertFalse(json.loads(response.content)["available"]) + + def test_error_handling(self): + """Error thrown while calling availabilityAPI returns error.""" + request = self.factory.get(API_BASE_PATH + "errordomain.gov") + request.user = self.user # domain set to raise error returns false for availability and error message error_domain_response = available(request, domain="errordomain.gov") self.assertFalse(json.loads(error_domain_response.content)["available"]) self.assertIn("Error finding domain availability", json.loads(error_domain_response.content)["message"]) - class AvailableAPITest(MockEppLib): """Test that the API can be called as expected.""" From 91077e7da0e54f4d51b51d6faae54e9d4491d922 Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Thu, 30 Nov 2023 11:12:08 -0800 Subject: [PATCH 06/19] remove try catch block in availabile check --- src/api/views.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/api/views.py b/src/api/views.py index d01acaa3f..d16e7af7f 100644 --- a/src/api/views.py +++ b/src/api/views.py @@ -67,14 +67,12 @@ def check_domain_available(domain): a match. """ Domain = apps.get_model("registrar.Domain") - try: - if domain.endswith(".gov"): - return Domain.available(domain) - else: - # domain search string doesn't end with .gov, add it on here - return Domain.available(domain + ".gov") - except Exception as err: - raise err + if domain.endswith(".gov"): + return Domain.available(domain) + else: + # domain search string doesn't end with .gov, add it on here + return Domain.available(domain + ".gov") + @require_http_methods(["GET"]) From ba87db7c56ed41493f7d637a86b4bd4a5c0e3b9f Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Thu, 30 Nov 2023 11:23:37 -0800 Subject: [PATCH 07/19] update error to cannot_contact_registry --- src/api/tests/test_available.py | 4 +++- src/api/views.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/api/tests/test_available.py b/src/api/tests/test_available.py index 2bd6c70a6..eb8385c0a 100644 --- a/src/api/tests/test_available.py +++ b/src/api/tests/test_available.py @@ -8,6 +8,7 @@ from django.test import RequestFactory from ..views import available, check_domain_available from .common import less_console_noise from registrar.tests.common import MockEppLib +from registrar.utility.errors import GenericError, GenericErrorCodes from unittest.mock import call from epplibwrapper import ( @@ -115,7 +116,8 @@ class AvailableViewTest(MockEppLib): # domain set to raise error returns false for availability and error message error_domain_response = available(request, domain="errordomain.gov") self.assertFalse(json.loads(error_domain_response.content)["available"]) - self.assertIn("Error finding domain availability", json.loads(error_domain_response.content)["message"]) + self.assertEqual(GenericError._error_mapping[GenericErrorCodes.CANNOT_CONTACT_REGISTRY], + json.loads(error_domain_response.content)["message"]) class AvailableAPITest(MockEppLib): diff --git a/src/api/views.py b/src/api/views.py index d16e7af7f..0e51f4392 100644 --- a/src/api/views.py +++ b/src/api/views.py @@ -5,6 +5,7 @@ from django.http import JsonResponse from django.utils.safestring import mark_safe from registrar.templatetags.url_helpers import public_site_url +from registrar.utility.errors import GenericError, GenericErrorCodes import requests @@ -30,8 +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": "Error finding domain availability. Please wait a few minutes and try again.\ - If you continue to receive this error after a few tries, contact help@get.gov", + "error": GenericError._error_mapping[GenericErrorCodes.CANNOT_CONTACT_REGISTRY], } From 77964522830723a36edb9bdb4f361e85d1c5ac06 Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Thu, 30 Nov 2023 11:24:20 -0800 Subject: [PATCH 08/19] Fix lint errors --- src/api/tests/test_available.py | 7 +++++-- src/api/views.py | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/api/tests/test_available.py b/src/api/tests/test_available.py index eb8385c0a..956d5e858 100644 --- a/src/api/tests/test_available.py +++ b/src/api/tests/test_available.py @@ -116,8 +116,11 @@ class AvailableViewTest(MockEppLib): # domain set to raise error returns false for availability and error message error_domain_response = available(request, domain="errordomain.gov") self.assertFalse(json.loads(error_domain_response.content)["available"]) - self.assertEqual(GenericError._error_mapping[GenericErrorCodes.CANNOT_CONTACT_REGISTRY], - json.loads(error_domain_response.content)["message"]) + self.assertEqual( + GenericError._error_mapping[GenericErrorCodes.CANNOT_CONTACT_REGISTRY], + json.loads(error_domain_response.content)["message"], + ) + class AvailableAPITest(MockEppLib): diff --git a/src/api/views.py b/src/api/views.py index 0e51f4392..f84f4439f 100644 --- a/src/api/views.py +++ b/src/api/views.py @@ -74,7 +74,6 @@ def check_domain_available(domain): return Domain.available(domain + ".gov") - @require_http_methods(["GET"]) @login_not_required def available(request, domain=""): From 4588a02d44dbb719e09596965ac70256c584d92f Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Thu, 30 Nov 2023 13:25:55 -0800 Subject: [PATCH 09/19] Add period to registry error message --- src/registrar/utility/errors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registrar/utility/errors.py b/src/registrar/utility/errors.py index 52b1ea1d3..486f00597 100644 --- a/src/registrar/utility/errors.py +++ b/src/registrar/utility/errors.py @@ -42,7 +42,7 @@ class GenericError(Exception): GenericErrorCodes.CANNOT_CONTACT_REGISTRY: """ We’re experiencing a system connection error. Please wait a few minutes and try again. If you continue to receive this error after a few tries, -contact help@get.gov +contact help@get.gov. """, GenericErrorCodes.GENERIC_ERROR: ("Value entered was wrong."), } From 5f68677d7fb079de059093fea1562fcc66bc3454 Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Thu, 30 Nov 2023 16:23:20 -0800 Subject: [PATCH 10/19] Raise system error message on EPP fail --- src/registrar/forms/application_wizard.py | 5 +++++ src/registrar/models/utility/domain_helper.py | 8 ++++++-- src/registrar/utility/errors.py | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/registrar/forms/application_wizard.py b/src/registrar/forms/application_wizard.py index a70c23e52..428215fc0 100644 --- a/src/registrar/forms/application_wizard.py +++ b/src/registrar/forms/application_wizard.py @@ -392,6 +392,7 @@ CurrentSitesFormSet = forms.formset_factory( class AlternativeDomainForm(RegistrarForm): def clean_alternative_domain(self): """Validation code for domain names.""" + try: requested = self.cleaned_data.get("alternative_domain", None) validated = DraftDomain.validate(requested, blank_ok=True) @@ -399,6 +400,8 @@ class AlternativeDomainForm(RegistrarForm): raise forms.ValidationError(DOMAIN_API_MESSAGES["extra_dots"], code="extra_dots") except errors.DomainUnavailableError: raise forms.ValidationError(DOMAIN_API_MESSAGES["unavailable"], code="unavailable") + except errors.RegistrySystemError: + raise forms.ValidationError(DOMAIN_API_MESSAGES["error"], code="error") except ValueError: raise forms.ValidationError(DOMAIN_API_MESSAGES["invalid"], code="invalid") return validated @@ -484,6 +487,8 @@ class DotGovDomainForm(RegistrarForm): raise forms.ValidationError(DOMAIN_API_MESSAGES["extra_dots"], code="extra_dots") except errors.DomainUnavailableError: raise forms.ValidationError(DOMAIN_API_MESSAGES["unavailable"], code="unavailable") + except errors.RegistrySystemError: + raise forms.ValidationError(DOMAIN_API_MESSAGES["error"], code="error") except ValueError: raise forms.ValidationError(DOMAIN_API_MESSAGES["invalid"], code="invalid") return validated diff --git a/src/registrar/models/utility/domain_helper.py b/src/registrar/models/utility/domain_helper.py index 49badd5d7..5e4360fad 100644 --- a/src/registrar/models/utility/domain_helper.py +++ b/src/registrar/models/utility/domain_helper.py @@ -2,6 +2,7 @@ import re from api.views import check_domain_available from registrar.utility import errors +from registrar.utility.errors import GenericError, GenericErrorCodes class DomainHelper: @@ -40,8 +41,11 @@ class DomainHelper: raise errors.ExtraDotsError() if not DomainHelper.string_could_be_domain(domain + ".gov"): raise ValueError() - if not check_domain_available(domain): - raise errors.DomainUnavailableError() + try: + if not check_domain_available(domain): + raise errors.DomainUnavailableError() + except Exception: + raise errors.RegistrySystemError() return domain @classmethod diff --git a/src/registrar/utility/errors.py b/src/registrar/utility/errors.py index 486f00597..93b8855f3 100644 --- a/src/registrar/utility/errors.py +++ b/src/registrar/utility/errors.py @@ -13,6 +13,10 @@ class DomainUnavailableError(ValueError): pass +class RegistrySystemError(ValueError): + pass + + class ActionNotAllowed(Exception): """User accessed an action that is not allowed by the current state""" From 0c12676d2763e44b6e0cb7b349e895e6e668fd92 Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Thu, 30 Nov 2023 16:25:41 -0800 Subject: [PATCH 11/19] Remove unused import --- src/registrar/models/utility/domain_helper.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/registrar/models/utility/domain_helper.py b/src/registrar/models/utility/domain_helper.py index 5e4360fad..a3c71dc0d 100644 --- a/src/registrar/models/utility/domain_helper.py +++ b/src/registrar/models/utility/domain_helper.py @@ -2,7 +2,6 @@ import re from api.views import check_domain_available from registrar.utility import errors -from registrar.utility.errors import GenericError, GenericErrorCodes class DomainHelper: From e62cf84def72beb3e033f50fcb1723ba15f41519 Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Thu, 30 Nov 2023 16:26:22 -0800 Subject: [PATCH 12/19] Remove unused whitespace --- src/registrar/forms/application_wizard.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/registrar/forms/application_wizard.py b/src/registrar/forms/application_wizard.py index 428215fc0..03207087f 100644 --- a/src/registrar/forms/application_wizard.py +++ b/src/registrar/forms/application_wizard.py @@ -392,7 +392,6 @@ CurrentSitesFormSet = forms.formset_factory( class AlternativeDomainForm(RegistrarForm): def clean_alternative_domain(self): """Validation code for domain names.""" - try: requested = self.cleaned_data.get("alternative_domain", None) validated = DraftDomain.validate(requested, blank_ok=True) From db14ddc45d1df7704437ed7b69b6dde6cebca4e0 Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Thu, 30 Nov 2023 17:05:23 -0800 Subject: [PATCH 13/19] Fix lint errors --- src/registrar/models/utility/domain_helper.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/registrar/models/utility/domain_helper.py b/src/registrar/models/utility/domain_helper.py index a3c71dc0d..14cae53bc 100644 --- a/src/registrar/models/utility/domain_helper.py +++ b/src/registrar/models/utility/domain_helper.py @@ -29,11 +29,8 @@ class DomainHelper: if not isinstance(domain, str): raise ValueError("Domain name must be a string") domain = domain.lower().strip() - if domain == "": - if blank_ok: - return domain - else: - raise errors.BlankValueError() + if domain == "" and not blank_ok: + raise errors.BlankValueError() if domain.endswith(".gov"): domain = domain[:-4] if "." in domain: From 578f5bac1a3c888e39b63ebc194db0e383759449 Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Fri, 1 Dec 2023 10:10:25 -0800 Subject: [PATCH 14/19] Make class function for GenericError mapping --- src/api/views.py | 2 +- src/registrar/utility/errors.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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 From 63b2c1c699f7069aa86fb8ac106b1303008eb819 Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Fri, 1 Dec 2023 10:11:37 -0800 Subject: [PATCH 15/19] Rename error mapping method --- src/registrar/utility/errors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registrar/utility/errors.py b/src/registrar/utility/errors.py index 7edf11deb..9463c1387 100644 --- a/src/registrar/utility/errors.py +++ b/src/registrar/utility/errors.py @@ -61,7 +61,7 @@ contact help@get.gov. return f"{self.message}" @classmethod - def get_error_mapping(self, code=None): + def get_error_message(self, code=None): return self._error_mapping.get(code) From 5e8e50dcbc4e7035faa275e8aa6f1d3f1a98d215 Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Fri, 1 Dec 2023 10:33:04 -0800 Subject: [PATCH 16/19] Update API views --- src/api/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/views.py b/src/api/views.py index 10507fd7f..93d27a382 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.get_error_mapping(GenericErrorCodes.CANNOT_CONTACT_REGISTRY), + "error": GenericError.get_error_message(GenericErrorCodes.CANNOT_CONTACT_REGISTRY), } From 4d3c7b94f514e40ec3d5248b0cb39093ccdcc8ab Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Fri, 1 Dec 2023 10:34:34 -0800 Subject: [PATCH 17/19] Update availability test --- src/api/tests/test_available.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/tests/test_available.py b/src/api/tests/test_available.py index 956d5e858..9de152b06 100644 --- a/src/api/tests/test_available.py +++ b/src/api/tests/test_available.py @@ -117,7 +117,7 @@ class AvailableViewTest(MockEppLib): error_domain_response = available(request, domain="errordomain.gov") self.assertFalse(json.loads(error_domain_response.content)["available"]) self.assertEqual( - GenericError._error_mapping[GenericErrorCodes.CANNOT_CONTACT_REGISTRY], + GenericError.get_error_message(GenericErrorCodes.CANNOT_CONTACT_REGISTRY), json.loads(error_domain_response.content)["message"], ) From fa5ac29606697de42a9f2630bb93aba82d7e8bcb Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Fri, 1 Dec 2023 15:18:57 -0800 Subject: [PATCH 18/19] Specified error messages and function comments --- src/api/views.py | 2 +- src/registrar/models/utility/domain_helper.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/views.py b/src/api/views.py index 93d27a382..85ae021c9 100644 --- a/src/api/views.py +++ b/src/api/views.py @@ -64,7 +64,7 @@ def check_domain_available(domain): The given domain is lowercased to match against the domains list. If the given domain doesn't end with .gov, ".gov" is added when looking for - a match. + a match. If check fails, throws a RegistryError. """ Domain = apps.get_model("registrar.Domain") if domain.endswith(".gov"): diff --git a/src/registrar/models/utility/domain_helper.py b/src/registrar/models/utility/domain_helper.py index 14cae53bc..c8419ca54 100644 --- a/src/registrar/models/utility/domain_helper.py +++ b/src/registrar/models/utility/domain_helper.py @@ -40,8 +40,8 @@ class DomainHelper: try: if not check_domain_available(domain): raise errors.DomainUnavailableError() - except Exception: - raise errors.RegistrySystemError() + except RegistryError as err: + raise errors.RegistrySystemError() from err return domain @classmethod From b4c8ce26d47c2352cbd1c00c11b1ffd001780342 Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Fri, 1 Dec 2023 15:34:11 -0800 Subject: [PATCH 19/19] Add import for EPP RegistryError --- src/registrar/models/utility/domain_helper.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/registrar/models/utility/domain_helper.py b/src/registrar/models/utility/domain_helper.py index c8419ca54..e43661b1d 100644 --- a/src/registrar/models/utility/domain_helper.py +++ b/src/registrar/models/utility/domain_helper.py @@ -2,6 +2,7 @@ import re from api.views import check_domain_available from registrar.utility import errors +from epplibwrapper.errors import RegistryError class DomainHelper: