"""Create fallback_executor
Generated by Phi-Octopus Eden
2025-11-06 02:09:50.323740
"""

```python
from typing import Any, Callable, Optional


class FallbackExecutor:
    """
    A class that provides a mechanism for executing functions with fallback handling.

    Attributes:
        primary_func (Callable): The main function to be executed.
        fallback_func (Optional[Callable]): The function to execute if the primary function fails.
    """

    def __init__(self, primary_func: Callable, fallback_func: Optional[Callable] = None):
        """
        Initialize FallbackExecutor with a primary and optional fallback function.

        Args:
            primary_func (Callable): The main function to be executed.
            fallback_func (Optional[Callable], optional): The function to execute if the primary function fails. Defaults to None.
        """
        self.primary_func = primary_func
        self.fallback_func = fallback_func

    def execute(self, *args: Any, **kwargs: Any) -> Any:
        """
        Execute the primary function and handle potential exceptions with a fallback.

        Args:
            *args: Variable length argument list for the primary function.
            **kwargs: Arbitrary keyword arguments for the primary function.

        Returns:
            The result of the primary function or the fallback function if an exception occurs.

        Raises:
            Any exception raised by the primary function, unless caught and handled by the fallback.
        """
        try:
            return self.primary_func(*args, **kwargs)
        except Exception as e:
            print(f"Primary function failed: {e}")
            if self.fallback_func is not None:
                try:
                    return self.fallback_func(*args, **kwargs)
                except Exception as e:
                    print(f"Fallback function also failed: {e}")
                    raise

# Example usage
def add(a: int, b: int) -> int:
    """Add two numbers."""
    return a + b

def subtract(a: int, b: int) -> int:
    """Subtract two numbers."""
    return a - b

fallback_executor = FallbackExecutor(add, subtract)
result = fallback_executor.execute(10, 5)  # Expected to succeed
print(result)

try:
    result = fallback_executor.execute(10, '5')  # Expected to fail and use the fallback
except Exception as e:
    print(e)
```