mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-06-11 06:54:48 +02:00
Raise system error message on EPP fail
This commit is contained in:
parent
4588a02d44
commit
5f68677d7f
3 changed files with 15 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue