first refactor attempt, moving send_domain_invitation_email to a helper

This commit is contained in:
David Kennedy 2024-12-13 06:48:47 -05:00
parent d766aa9b2a
commit d2d44bfea1
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
4 changed files with 150 additions and 120 deletions

View file

@ -23,6 +23,34 @@ class InvalidDomainError(ValueError):
pass
class InvitationError(Exception):
"""Base exception for invitation-related errors."""
pass
class AlreadyManagerError(InvitationError):
"""Raised when the user is already a manager for the domain."""
def __init__(self, email):
super().__init__(f"{email} is already a manager for this domain.")
class AlreadyInvitedError(InvitationError):
"""Raised when the user has already been invited to the domain."""
def __init__(self, email):
super().__init__(f"{email} has already been invited to this domain.")
class MissingEmailError(InvitationError):
"""Raised when the requestor has no email associated with their account."""
def __init__(self, username):
super().__init__(f"Can't send invitation email. No email is associated with the account for '{username}'.")
self.username = username
class OutsideOrgMemberError(ValueError):
"""
Error raised when an org member tries adding a user from a different .gov org.