Major WHOOSH system refactoring and feature enhancements
- Migrated from HIVE branding to WHOOSH across all components - Enhanced backend API with new services: AI models, BZZZ integration, templates, members - Added comprehensive testing suite with security, performance, and integration tests - Improved frontend with new components for project setup, AI models, and team management - Updated MCP server implementation with WHOOSH-specific tools and resources - Enhanced deployment configurations with production-ready Docker setups - Added comprehensive documentation and setup guides - Implemented age encryption service and UCXL integration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Centralized Error Handling for Hive API
|
||||
Centralized Error Handling for WHOOSH API
|
||||
|
||||
This module provides standardized error handling, response formatting,
|
||||
and HTTP status code management across all API endpoints.
|
||||
@@ -26,9 +26,9 @@ from ..models.responses import ErrorResponse
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HiveAPIException(HTTPException):
|
||||
class WHOOSHAPIException(HTTPException):
|
||||
"""
|
||||
Custom exception class for Hive API with enhanced error details.
|
||||
Custom exception class for WHOOSH API with enhanced error details.
|
||||
|
||||
Extends FastAPI's HTTPException with additional context and
|
||||
standardized error formatting.
|
||||
@@ -49,7 +49,7 @@ class HiveAPIException(HTTPException):
|
||||
|
||||
# Standard error codes
|
||||
class ErrorCodes:
|
||||
"""Standard error codes used across the Hive API"""
|
||||
"""Standard error codes used across the WHOOSH API"""
|
||||
|
||||
# Authentication & Authorization
|
||||
INVALID_CREDENTIALS = "INVALID_CREDENTIALS"
|
||||
@@ -83,9 +83,9 @@ class ErrorCodes:
|
||||
|
||||
|
||||
# Common HTTP exceptions with proper error codes
|
||||
def agent_not_found_error(agent_id: str) -> HiveAPIException:
|
||||
def agent_not_found_error(agent_id: str) -> WHOOSHAPIException:
|
||||
"""Standard agent not found error"""
|
||||
return HiveAPIException(
|
||||
return WHOOSHAPIException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail=f"Agent with ID '{agent_id}' not found",
|
||||
error_code=ErrorCodes.AGENT_NOT_FOUND,
|
||||
@@ -93,9 +93,9 @@ def agent_not_found_error(agent_id: str) -> HiveAPIException:
|
||||
)
|
||||
|
||||
|
||||
def agent_already_exists_error(agent_id: str) -> HiveAPIException:
|
||||
def agent_already_exists_error(agent_id: str) -> WHOOSHAPIException:
|
||||
"""Standard agent already exists error"""
|
||||
return HiveAPIException(
|
||||
return WHOOSHAPIException(
|
||||
status_code=status.HTTP_409_CONFLICT,
|
||||
detail=f"Agent with ID '{agent_id}' already exists",
|
||||
error_code=ErrorCodes.AGENT_ALREADY_EXISTS,
|
||||
@@ -103,9 +103,9 @@ def agent_already_exists_error(agent_id: str) -> HiveAPIException:
|
||||
)
|
||||
|
||||
|
||||
def task_not_found_error(task_id: str) -> HiveAPIException:
|
||||
def task_not_found_error(task_id: str) -> WHOOSHAPIException:
|
||||
"""Standard task not found error"""
|
||||
return HiveAPIException(
|
||||
return WHOOSHAPIException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail=f"Task with ID '{task_id}' not found",
|
||||
error_code=ErrorCodes.TASK_NOT_FOUND,
|
||||
@@ -113,9 +113,9 @@ def task_not_found_error(task_id: str) -> HiveAPIException:
|
||||
)
|
||||
|
||||
|
||||
def coordinator_unavailable_error() -> HiveAPIException:
|
||||
def coordinator_unavailable_error() -> WHOOSHAPIException:
|
||||
"""Standard coordinator unavailable error"""
|
||||
return HiveAPIException(
|
||||
return WHOOSHAPIException(
|
||||
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
|
||||
detail="Coordinator service is currently unavailable",
|
||||
error_code=ErrorCodes.SERVICE_UNAVAILABLE,
|
||||
@@ -123,9 +123,9 @@ def coordinator_unavailable_error() -> HiveAPIException:
|
||||
)
|
||||
|
||||
|
||||
def database_error(operation: str, details: Optional[str] = None) -> HiveAPIException:
|
||||
def database_error(operation: str, details: Optional[str] = None) -> WHOOSHAPIException:
|
||||
"""Standard database error"""
|
||||
return HiveAPIException(
|
||||
return WHOOSHAPIException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
detail=f"Database operation failed: {operation}",
|
||||
error_code=ErrorCodes.DATABASE_ERROR,
|
||||
@@ -133,9 +133,9 @@ def database_error(operation: str, details: Optional[str] = None) -> HiveAPIExce
|
||||
)
|
||||
|
||||
|
||||
def validation_error(field: str, message: str) -> HiveAPIException:
|
||||
def validation_error(field: str, message: str) -> WHOOSHAPIException:
|
||||
"""Standard validation error"""
|
||||
return HiveAPIException(
|
||||
return WHOOSHAPIException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=f"Validation failed for field '{field}': {message}",
|
||||
error_code=ErrorCodes.VALIDATION_ERROR,
|
||||
@@ -144,15 +144,15 @@ def validation_error(field: str, message: str) -> HiveAPIException:
|
||||
|
||||
|
||||
# Global exception handlers
|
||||
async def hive_exception_handler(request: Request, exc: HiveAPIException) -> JSONResponse:
|
||||
async def whoosh_exception_handler(request: Request, exc: WHOOSHAPIException) -> JSONResponse:
|
||||
"""
|
||||
Global exception handler for HiveAPIException.
|
||||
Global exception handler for WHOOSHAPIException.
|
||||
|
||||
Converts HiveAPIException to properly formatted JSON response
|
||||
Converts WHOOSHAPIException to properly formatted JSON response
|
||||
with standardized error structure.
|
||||
"""
|
||||
logger.error(
|
||||
f"HiveAPIException: {exc.status_code} - {exc.detail}",
|
||||
f"WHOOSHAPIException: {exc.status_code} - {exc.detail}",
|
||||
extra={
|
||||
"error_code": exc.error_code,
|
||||
"details": exc.details,
|
||||
|
||||
Reference in New Issue
Block a user