"""
Custom exceptions for Galaxy Brain MCP
"""
from typing import Any, Dict, Optional
class GalaxyBrainError(Exception):
"""Base exception for Galaxy Brain"""
def __init__(
self,
message: str,
details: Optional[Dict[str, Any]] = None,
suggestion: Optional[str] = None
):
super().__init__(message)
self.message = message
self.details = details or {}
self.suggestion = suggestion
def to_dict(self) -> Dict[str, Any]:
"""Convert to dictionary for serialization"""
result = {
'error': self.__class__.__name__,
'message': self.message
}
if self.details:
result['details'] = self.details
if self.suggestion:
result['suggestion'] = self.suggestion
return result
class ThinkingError(GalaxyBrainError):
"""Error during thinking/planning phase"""
pass
class DoingError(GalaxyBrainError):
"""Error during execution phase"""
pass
class BridgeError(GalaxyBrainError):
"""Error converting thoughts to actions"""
pass
class ValidationError(GalaxyBrainError):
"""Input validation error"""
pass
class TimeoutError(GalaxyBrainError):
"""Operation timeout error"""
pass
class ExecutionError(GalaxyBrainError):
"""Execution failure error"""
pass
class SecurityError(GalaxyBrainError):
"""Security violation error"""
pass
class BranchError(ThinkingError):
"""Error with thought branching"""
pass
class RevisionError(ThinkingError):
"""Error revising a thought"""
pass
class VariableSubstitutionError(DoingError):
"""Error substituting variables from previous results"""
pass
class ServiceNotFoundError(DoingError):
"""Requested service not available"""
pass