from enum import Enum


class ConfigErrorCodes(int, Enum):
    """Configuration-related error codes (1000-1099)"""
    LOAD_BASE_CONFIG_ERROR = 1000
    UPDATE_CONFIG_ERROR = 1001 
    INIT_CONFIG_ERROR = 1002

class ToolErrorCodes(int, Enum):
    """MCP Server-related error codes (1500-1599)"""
    TOOL_LISTING_ERROR = 1500
    TOOL_REGISTRATION_ERROR = 1501
    TOOL_EXECUTION_ERROR = 1502

class StdioErrorCodes(int, Enum):
    """Stdio-related error codes (1600-1699)"""
    INIT_STDIO_SERVER_ERROR = 1600

class HTTPAppErrorCodes(int, Enum):
    """HTTP App-related error codes (2000-2099)"""
    INIT_FASTMCP_ERROR = 2000
    TOOLS_REGISTRATION_ERROR = 2001
    TOOLS_GETTING_ERROR = 2002
    INIT_HTTP_SERVER_ERROR = 2003

class GeneralErrorCodes(int, Enum):
    """General error codes (3000-3099)"""
    SERVER_ERROR = 3000
    CLIENT_ERROR = 3001

class ErrorCodeValidator:
    """Utility class for validating error codes"""

    @staticmethod
    def is_server_error(code: int) -> bool:
        """
        Check if the given code is a server-side error.
        
        Args:
            code: The error code to check
            
        Returns:
            bool: True if the code is a server-side error, False otherwise
        """
        server_errors = [
            *[e.value for e in ConfigErrorCodes],
            *[e.value for e in StdioErrorCodes],
            *[e.value for e in HTTPAppErrorCodes],
        ]
        return code in server_errors
    
    @staticmethod
    def is_client_error(code: int) -> bool:
        """
        Check if the given code is a client-side error.
        
        Args:
            code: The error code to check
            
        Returns:
            bool: True if the code is a client-side error, False otherwise
        """
        client_errors = [
            GeneralErrorCodes.CLIENT_ERROR.value
        ]
        return code in client_errors
