diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 598b612b5..6dc6cd94d 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -16,7 +16,7 @@ from dateutil.relativedelta import relativedelta # type: ignore from epplibwrapper.errors import ErrorCode, RegistryError from registrar.models import Contact, Domain, DomainApplication, DraftDomain, User, Website from registrar.utility import csv_export -from registrar.utility.errors import ApplicationStatusError, FSMErrorCodes +from registrar.utility.errors import FSMApplicationError, FSMErrorCodes from registrar.views.utility.mixins import OrderableFieldsMixin from django.contrib.admin.views.main import ORDER_VAR from registrar.widgets import NoAutocompleteFilteredSelectMultiple @@ -167,9 +167,9 @@ class DomainApplicationAdminForm(forms.ModelForm): error_message = None if investigator is None: # Lets grab the error message from a common location - error_message = ApplicationStatusError.get_error_message(FSMErrorCodes.NO_INVESTIGATOR) + error_message = FSMApplicationError.get_error_message(FSMErrorCodes.NO_INVESTIGATOR) elif not investigator.is_staff: - error_message = ApplicationStatusError.get_error_message(FSMErrorCodes.INVESTIGATOR_NOT_STAFF) + error_message = FSMApplicationError.get_error_message(FSMErrorCodes.INVESTIGATOR_NOT_STAFF) else: is_valid = True @@ -1225,11 +1225,11 @@ class DomainApplicationAdmin(ListHeaderAdmin): obj.status = original_obj.status # Try to perform the status change. - # Catch ApplicationStatusError's and return the message, + # Catch FSMApplicationError's and return the message, # as these are typically user errors. try: selected_method() - except ApplicationStatusError as err: + except FSMApplicationError as err: logger.warning(f"An error encountered when trying to change status: {err}") error_message = err.message diff --git a/src/registrar/models/domain_application.py b/src/registrar/models/domain_application.py index 29c4d63a5..6076497ad 100644 --- a/src/registrar/models/domain_application.py +++ b/src/registrar/models/domain_application.py @@ -9,7 +9,7 @@ from django.db import models from django_fsm import FSMField, transition # type: ignore from django.utils import timezone from registrar.models.domain import Domain -from registrar.utility.errors import ApplicationStatusError, FSMErrorCodes +from registrar.utility.errors import FSMApplicationError, FSMErrorCodes from .utility.time_stamped_model import TimeStampedModel from ..utility.email import send_templated_email, EmailSendingError @@ -791,7 +791,7 @@ class DomainApplication(TimeStampedModel): # == Check that the application is valid == # if Domain.objects.filter(name=self.requested_domain.name).exists(): - raise ApplicationStatusError(code=FSMErrorCodes.APPROVE_DOMAIN_IN_USE) + raise FSMApplicationError(code=FSMErrorCodes.APPROVE_DOMAIN_IN_USE) # == Create the domain and related components == # created_domain = Domain.objects.create(name=self.requested_domain.name) diff --git a/src/registrar/utility/errors.py b/src/registrar/utility/errors.py index 10e1809aa..f5804ac2f 100644 --- a/src/registrar/utility/errors.py +++ b/src/registrar/utility/errors.py @@ -71,8 +71,6 @@ class GenericError(Exception): return self._error_mapping.get(code) -# (Q for reviewers) What should this be called? -# Not a fan of this name. class FSMErrorCodes(IntEnum): """Used when doing FSM transitions. Overview of generic error codes: @@ -88,9 +86,7 @@ class FSMErrorCodes(IntEnum): INVESTIGATOR_NOT_SUBMITTER = 4 -# (Q for reviewers) What should this be called? -# Not a fan of this name. -class ApplicationStatusError(Exception): +class FSMApplicationError(Exception): """ Used to raise exceptions when doing FSM Transitions. Uses `FSMErrorCodes` as an enum.