Files
crewAI/src/crewai/utilities/errors.py
Greyson LaLonde 3e97393f58 chore: improve typing and consolidate utilities
- add type annotations across utility modules  
- refactor printer system, agent utils, and imports for consistency  
- remove unused modules, constants, and redundant patterns  
- improve runtime type checks, exception handling, and guardrail validation  
- standardize warning suppression and logging utilities  
- fix llm typing, threading/typing edge cases, and test behavior
2025-09-23 11:33:46 -04:00

57 lines
1.8 KiB
Python

"""Error message definitions for CrewAI database operations.
This module provides standardized error classes and message templates
for database operations and agent repository handling.
"""
from typing import Final
class DatabaseOperationError(Exception):
"""Base exception class for database operation errors.
Attributes:
original_error: The original exception that caused this error, if any.
"""
def __init__(self, message: str, original_error: Exception | None = None) -> None:
"""Initialize the database operation error.
Args:
message: The error message to display
original_error: The original exception that caused this error, if any
"""
super().__init__(message)
self.original_error = original_error
class DatabaseError:
"""Standardized error message templates for database operations.
Provides consistent error message formatting for various database
operation failures.
"""
INIT_ERROR: Final[str] = "Database initialization error: {}"
SAVE_ERROR: Final[str] = "Error saving task outputs: {}"
UPDATE_ERROR: Final[str] = "Error updating task outputs: {}"
LOAD_ERROR: Final[str] = "Error loading task outputs: {}"
DELETE_ERROR: Final[str] = "Error deleting task outputs: {}"
@classmethod
def format_error(cls, template: str, error: Exception) -> str:
"""Format an error message with the given template and error.
Args:
template: The error message template to use
error: The exception to format into the template
Returns:
The formatted error message
"""
return template.format(str(error))
class AgentRepositoryError(Exception):
"""Exception raised when an agent repository is not found."""