docs: add AI code generation requirements and comprehensive Google-style docstrings
- Add AI code generation requirements to AGENTS.md - Add module-level docstrings to all 46 Python modules - Add detailed Google-style docstrings to all classes and functions - Remove all inline comments following self-documenting code principle - Include Args, Returns, Raises sections in function docstrings - Add Attributes and Examples sections to class docstrings
This commit is contained in:
@@ -1,39 +1,78 @@
|
||||
"""Domain exceptions."""
|
||||
"""Domain exceptions for business logic errors.
|
||||
|
||||
This module defines the exception hierarchy for domain layer errors.
|
||||
All domain exceptions inherit from DomainException base class.
|
||||
"""
|
||||
|
||||
|
||||
class DomainException(Exception):
|
||||
"""Base exception for domain layer."""
|
||||
"""Base exception for domain layer.
|
||||
|
||||
All domain-specific exceptions should inherit from this class.
|
||||
Provides a consistent interface for error messages.
|
||||
|
||||
Attributes:
|
||||
message: Human-readable error description.
|
||||
|
||||
Example:
|
||||
>>> raise DomainException("Business rule violated")
|
||||
"""
|
||||
|
||||
def __init__(self, message: str) -> None:
|
||||
"""Initialize domain exception.
|
||||
|
||||
Args:
|
||||
message: Error message describing the exception.
|
||||
"""
|
||||
self.message = message
|
||||
super().__init__(self.message)
|
||||
|
||||
|
||||
class ValidationException(DomainException):
|
||||
"""Raised when validation fails."""
|
||||
"""Raised when validation fails.
|
||||
|
||||
pass
|
||||
Used when entity or value object validation does not pass.
|
||||
|
||||
Example:
|
||||
>>> raise ValidationException("Title is too long")
|
||||
"""
|
||||
|
||||
|
||||
class NotFoundException(DomainException):
|
||||
"""Raised when an entity is not found."""
|
||||
"""Raised when an entity is not found.
|
||||
|
||||
pass
|
||||
Used when requesting an entity that does not exist in the repository.
|
||||
|
||||
Example:
|
||||
>>> raise NotFoundException("Post with id 123 not found")
|
||||
"""
|
||||
|
||||
|
||||
class AlreadyExistsException(DomainException):
|
||||
"""Raised when trying to create an entity that already exists."""
|
||||
"""Raised when trying to create an entity that already exists.
|
||||
|
||||
pass
|
||||
Used when attempting to create a duplicate entity.
|
||||
|
||||
Example:
|
||||
>>> raise AlreadyExistsException("Post with this slug already exists")
|
||||
"""
|
||||
|
||||
|
||||
class UnauthorizedException(DomainException):
|
||||
"""Raised when user is not authorized."""
|
||||
"""Raised when user is not authorized.
|
||||
|
||||
pass
|
||||
Used when authentication is required but not provided or invalid.
|
||||
|
||||
Example:
|
||||
>>> raise UnauthorizedException("Authentication required")
|
||||
"""
|
||||
|
||||
|
||||
class ForbiddenException(DomainException):
|
||||
"""Raised when access is forbidden."""
|
||||
"""Raised when access is forbidden.
|
||||
|
||||
pass
|
||||
Used when authenticated user lacks required permissions.
|
||||
|
||||
Example:
|
||||
>>> raise ForbiddenException("Only admins can delete posts")
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user