Some checks failed
CD - Build & Deploy / build-and-push (push) Has been cancelled
CD - Build & Deploy / package-helm (push) Has been cancelled
CD - Build & Deploy / deploy-staging (push) Has been cancelled
CD - Build & Deploy / deploy-production (push) Has been cancelled
CD - Build & Deploy / release (push) Has been cancelled
CI / test (3.11) (push) Has been cancelled
CI / test (3.12) (push) Has been cancelled
CI / security (push) Has been cancelled
- Implemented Clean Architecture with Domain, Application, Infrastructure, Presentation layers - Added comprehensive project structure following SOLID principles - Created Kubernetes deployment with Helm charts (HPA, PDB, NetworkPolicy) - Configured ArgoCD for automated deployment (production + staging) - Implemented CI/CD pipeline with GitHub Actions - Added comprehensive documentation (handbook, architecture, coding standards) - Configured PostgreSQL, Redis, Celery for backend services - Created modern landing page with Persian fonts (Vazirmatn) - Added Docker multi-stage build for production - Configured development tools (pytest, black, flake8, mypy, isort) - Added pre-commit hooks for code quality - Implemented Makefile for common operations
105 lines
2.7 KiB
Python
105 lines
2.7 KiB
Python
"""User-related domain exceptions."""
|
|
|
|
from src.core.domain.exceptions.base import DomainException, ValidationException
|
|
|
|
|
|
class UserNotFoundException(DomainException):
|
|
"""User not found exception."""
|
|
|
|
def __init__(self, user_id: int = None, email: str = None):
|
|
"""Initialize exception.
|
|
|
|
Args:
|
|
user_id: User ID
|
|
email: User email
|
|
"""
|
|
if user_id:
|
|
message = f"User with ID {user_id} not found"
|
|
elif email:
|
|
message = f"User with email {email} not found"
|
|
else:
|
|
message = "User not found"
|
|
super().__init__(message, "USER_NOT_FOUND")
|
|
|
|
|
|
class EmailAlreadyExistsException(DomainException):
|
|
"""Email already exists exception."""
|
|
|
|
def __init__(self, email: str):
|
|
"""Initialize exception.
|
|
|
|
Args:
|
|
email: Email address
|
|
"""
|
|
super().__init__(
|
|
f"Email {email} is already registered",
|
|
"EMAIL_ALREADY_EXISTS"
|
|
)
|
|
|
|
|
|
class InvalidEmailException(ValidationException):
|
|
"""Invalid email format exception."""
|
|
|
|
def __init__(self, email: str):
|
|
"""Initialize exception.
|
|
|
|
Args:
|
|
email: Invalid email
|
|
"""
|
|
super().__init__(
|
|
f"Invalid email format: {email}",
|
|
field="email"
|
|
)
|
|
|
|
|
|
class WeakPasswordException(ValidationException):
|
|
"""Weak password exception."""
|
|
|
|
def __init__(self, reason: str = "Password does not meet requirements"):
|
|
"""Initialize exception.
|
|
|
|
Args:
|
|
reason: Reason why password is weak
|
|
"""
|
|
super().__init__(reason, field="password")
|
|
|
|
|
|
class InvalidCredentialsException(DomainException):
|
|
"""Invalid login credentials exception."""
|
|
|
|
def __init__(self):
|
|
"""Initialize exception."""
|
|
super().__init__(
|
|
"Invalid email or password",
|
|
"INVALID_CREDENTIALS"
|
|
)
|
|
|
|
|
|
class AccountLockedException(DomainException):
|
|
"""Account is locked exception."""
|
|
|
|
def __init__(self, reason: str = "Account is locked"):
|
|
"""Initialize exception.
|
|
|
|
Args:
|
|
reason: Reason for lock
|
|
"""
|
|
super().__init__(reason, "ACCOUNT_LOCKED")
|
|
|
|
|
|
class InsufficientBalanceException(DomainException):
|
|
"""Insufficient wallet balance exception."""
|
|
|
|
def __init__(self, required: str, available: str):
|
|
"""Initialize exception.
|
|
|
|
Args:
|
|
required: Required amount
|
|
available: Available amount
|
|
"""
|
|
super().__init__(
|
|
f"Insufficient balance. Required: {required}, Available: {available}",
|
|
"INSUFFICIENT_BALANCE"
|
|
)
|
|
|