mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-12 02:37:45 +08:00
Refactor code structure and remove redundant changes
This commit is contained in:
59
codex-lens/build/lib/codexlens/errors.py
Normal file
59
codex-lens/build/lib/codexlens/errors.py
Normal file
@@ -0,0 +1,59 @@
|
||||
"""CodexLens exception hierarchy."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
class CodexLensError(Exception):
|
||||
"""Base class for all CodexLens errors."""
|
||||
|
||||
|
||||
class ConfigError(CodexLensError):
|
||||
"""Raised when configuration is invalid or cannot be loaded."""
|
||||
|
||||
|
||||
class ParseError(CodexLensError):
|
||||
"""Raised when parsing or indexing a file fails."""
|
||||
|
||||
|
||||
class StorageError(CodexLensError):
|
||||
"""Raised when reading/writing index storage fails.
|
||||
|
||||
Attributes:
|
||||
message: Human-readable error description
|
||||
db_path: Path to the database file (if applicable)
|
||||
operation: The operation that failed (e.g., 'query', 'initialize', 'migrate')
|
||||
details: Additional context for debugging
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
message: str,
|
||||
db_path: str | None = None,
|
||||
operation: str | None = None,
|
||||
details: dict | None = None
|
||||
) -> None:
|
||||
super().__init__(message)
|
||||
self.message = message
|
||||
self.db_path = db_path
|
||||
self.operation = operation
|
||||
self.details = details or {}
|
||||
|
||||
def __str__(self) -> str:
|
||||
parts = [self.message]
|
||||
if self.db_path:
|
||||
parts.append(f"[db: {self.db_path}]")
|
||||
if self.operation:
|
||||
parts.append(f"[op: {self.operation}]")
|
||||
if self.details:
|
||||
detail_str = ", ".join(f"{k}={v}" for k, v in self.details.items())
|
||||
parts.append(f"[{detail_str}]")
|
||||
return " ".join(parts)
|
||||
|
||||
|
||||
class SearchError(CodexLensError):
|
||||
"""Raised when a search operation fails."""
|
||||
|
||||
|
||||
class IndexNotFoundError(CodexLensError):
|
||||
"""Raised when a project's index cannot be found."""
|
||||
|
||||
Reference in New Issue
Block a user