mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-26 22:55:18 -04:00
refactor(exceptions): dedupe src/exceptions via core re-export (#4785)
src/exceptions.py was a byte-for-byte duplicate of the canonical core/exceptions.py. Replace its class bodies with a re-export shim (mirroring the core/constants.py -> src/constants.py pattern) so the exception classes are defined in exactly one place. Also fix the stale "# src/exceptions.py" header comment in core/exceptions.py. No behavior change: both import paths resolve to the same class objects (verified by identity), so `except SessionNotFoundError` works regardless of which module it was imported from. Ran py_compile and pytest tests/test_app.py (12 passed). Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
# src/exceptions.py
|
||||
# core/exceptions.py
|
||||
"""Custom exceptions for the application."""
|
||||
|
||||
class SessionNotFoundError(Exception):
|
||||
|
||||
+19
-26
@@ -1,29 +1,22 @@
|
||||
# src/exceptions.py
|
||||
"""Custom exceptions for the application."""
|
||||
"""Backward-compatible shim — the single source of truth is core/exceptions.py.
|
||||
|
||||
class SessionNotFoundError(Exception):
|
||||
"""Raised when a requested session is not found."""
|
||||
def __init__(self, session_id: str):
|
||||
self.session_id = session_id
|
||||
super().__init__(f"Session '{session_id}' not found")
|
||||
Historically this module was a byte-for-byte duplicate of core/exceptions.py,
|
||||
which is the canonical definition (imported by app.py, core/__init__.py, and
|
||||
routes/chat_routes.py). To kill the drift, this now simply re-exports the
|
||||
exception classes from core.exceptions so there is exactly one place that
|
||||
defines them. Existing `from src.exceptions import ...` callers keep working.
|
||||
"""
|
||||
from core.exceptions import ( # noqa: F401
|
||||
SessionNotFoundError,
|
||||
InvalidFileUploadError,
|
||||
LLMServiceError,
|
||||
WebSearchError,
|
||||
)
|
||||
|
||||
class InvalidFileUploadError(Exception):
|
||||
"""Raised when a file upload fails validation."""
|
||||
def __init__(self, message: str, filename: str = None):
|
||||
self.filename = filename
|
||||
self.message = message
|
||||
super().__init__(message)
|
||||
|
||||
class LLMServiceError(Exception):
|
||||
"""Raised when there is an error communicating with the LLM service."""
|
||||
def __init__(self, message: str, endpoint: str = None):
|
||||
self.endpoint = endpoint
|
||||
self.message = message
|
||||
super().__init__(message)
|
||||
|
||||
class WebSearchError(Exception):
|
||||
"""Raised when there is an error with web search functionality."""
|
||||
def __init__(self, message: str, query: str = None):
|
||||
self.query = query
|
||||
self.message = message
|
||||
super().__init__(message)
|
||||
__all__ = [
|
||||
"SessionNotFoundError",
|
||||
"InvalidFileUploadError",
|
||||
"LLMServiceError",
|
||||
"WebSearchError",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user