forked from cardosofelipe/pragma-stack
- introduce custom repository exception hierarchy (DuplicateEntryError, IntegrityConstraintError, InvalidInputError) replacing raw ValueError - eliminate all direct repository imports and raw SQL from route layer - add UserService, SessionService, OrganizationService to service layer - add get_stats/get_org_distribution service methods replacing admin inline SQL - fix timing side-channel in authenticate_user via dummy bcrypt check - replace SHA-256 client secret fallback with explicit InvalidClientError - replace assert with InvalidGrantError in authorization code exchange - replace N+1 token revocation loops with bulk UPDATE statements - rename oauth account token fields (drop misleading 'encrypted' suffix) - add Alembic migration 0003 for token field column rename - add 45 new service/repository tests; 975 passing, 94% coverage
27 lines
731 B
Python
27 lines
731 B
Python
"""
|
|
Custom exceptions for the repository layer.
|
|
|
|
These exceptions allow services and routes to handle database-level errors
|
|
with proper semantics, without leaking SQLAlchemy internals.
|
|
"""
|
|
|
|
|
|
class RepositoryError(Exception):
|
|
"""Base for all repository-layer errors."""
|
|
|
|
|
|
class DuplicateEntryError(RepositoryError):
|
|
"""Raised on unique constraint violations. Maps to HTTP 409 Conflict."""
|
|
|
|
|
|
class IntegrityConstraintError(RepositoryError):
|
|
"""Raised on FK or check constraint violations."""
|
|
|
|
|
|
class RecordNotFoundError(RepositoryError):
|
|
"""Raised when an expected record doesn't exist."""
|
|
|
|
|
|
class InvalidInputError(RepositoryError):
|
|
"""Raised on bad pagination params, invalid UUIDs, or other invalid inputs."""
|