calute.core.errors#
Custom error types for better error handling in Calute.
This module defines a hierarchy of exception classes for precise error handling throughout the Calute framework. All exceptions inherit from CaluteError and provide detailed error information including context and debugging details.
The error hierarchy allows for: - Specific error catching at different levels - Detailed error messages with context - Preservation of original exceptions when wrapping - Structured error details for debugging
Example
>>> try:
...
... except FunctionExecutionError as e:
... print(f"Function {e.function_name} failed: {e.message}")
... if e.original_error:
... print(f"Original error: {e.original_error}")
- exception calute.core.errors.AgentError(agent_id: str, message: str, details: dict[str, Any] | None = None)[source]#
Bases:
CaluteErrorErrors related to agent operations.
Raised when agent-specific operations fail, such as agent initialization, switching, or execution errors.
- agent_id#
The ID of the agent that encountered the error.
- message#
Human-readable error message.
- details#
Additional structured error details.
- exception calute.core.errors.CaluteError(message: str, details: dict[str, Any] | None = None)[source]#
Bases:
ExceptionBase exception for all Calute errors.
This is the root exception class for the Calute framework. All custom exceptions should inherit from this class.
- message#
Human-readable error message.
- details#
Additional structured error details for debugging.
- exception calute.core.errors.CaluteMemoryError(operation: str, message: str, details: dict[str, Any] | None = None)[source]#
Bases:
CaluteErrorMemory store errors.
Raised when memory operations fail, including storage, retrieval, or consolidation errors.
- operation#
The memory operation that failed.
- message#
Human-readable error message.
- details#
Additional structured error details.
- exception calute.core.errors.CaluteTimeoutError(operation: str, timeout: float, details: dict[str, Any] | None = None)[source]#
Bases:
CaluteErrorFunction or operation timeout.
Raised when an operation exceeds its configured timeout duration.
- operation#
Name or description of the operation that timed out.
- timeout#
The timeout duration in seconds that was exceeded.
- details#
Additional structured error details.
- exception calute.core.errors.ClientError(client_type: str, message: str, original_error: Exception | None = None, details: dict[str, Any] | None = None)[source]#
Bases:
CaluteErrorLLM client errors.
Raised when LLM client operations fail, including API errors, connection issues, or response parsing errors.
- client_type#
Type of the LLM client (e.g., ‘openai’, ‘anthropic’).
- message#
Human-readable error message.
- original_error#
The original exception from the client library.
- details#
Additional structured error details.
- exception calute.core.errors.ConfigurationError(config_key: str, message: str, details: dict[str, Any] | None = None)[source]#
Bases:
CaluteErrorConfiguration errors.
Raised when configuration is invalid, missing, or cannot be loaded.
- config_key#
The configuration key or section that has issues.
- message#
Human-readable error message.
- details#
Additional structured error details.
- exception calute.core.errors.FunctionExecutionError(function_name: str, message: str, original_error: Exception | None = None, details: dict[str, Any] | None = None)[source]#
Bases:
CaluteErrorErrors during function execution.
Raised when a function/tool call fails during execution. Preserves the original exception for debugging.
- function_name#
Name of the function that failed.
- message#
Human-readable error message.
- original_error#
The original exception that caused the failure.
- details#
Additional structured error details.
- exception calute.core.errors.RateLimitError(resource: str, limit: int, window: str, retry_after: float | None = None, details: dict[str, Any] | None = None)[source]#
Bases:
CaluteErrorRate limit exceeded.
Raised when a rate limit is exceeded for API calls or operations.
- resource#
The resource or endpoint that is rate limited.
- limit#
The rate limit that was exceeded.
- window#
The time window for the rate limit (e.g., ‘minute’, ‘hour’).
- retry_after#
Optional time in seconds to wait before retrying.
- details#
Additional structured error details.
- exception calute.core.errors.ValidationError(field: str, message: str, value: Any = None, details: dict[str, Any] | None = None)[source]#
Bases:
CaluteErrorInput validation errors.
Raised when input validation fails for parameters, configurations, or user inputs.
- field#
The field or parameter that failed validation.
- message#
Human-readable validation error message.
- value#
The actual value that failed validation.
- details#
Additional structured error details.