"""Create fallback_executor
Generated by Phi-Octopus Eden
2025-11-08 13:25:59.895314
"""

```python
from typing import Callable, Any


class FallbackExecutor:
    """
    A class for executing a function with fallbacks in case of errors.

    Attributes:
        primary_executor (Callable): The main function to execute.
        secondary_executors (list[Callable]): A list of functions to try if the primary executor fails.
    """

    def __init__(self, primary_executor: Callable, secondary_executors: list[Callable] = None):
        """
        Initialize the FallbackExecutor with a primary and optional secondary executors.

        Args:
            primary_executor (Callable): The main function to execute.
            secondary_executors (list[Callable], optional): A list of fallback functions. Defaults to an empty list.
        """
        self.primary_executor = primary_executor
        self.secondary_executors = secondary_executors if secondary_executors else []

    def execute(self, *args, **kwargs) -> Any:
        """
        Execute the primary executor and fall back to secondary executors in case of errors.

        Args:
            *args: Positional arguments for the primary_executor.
            **kwargs: Keyword arguments for the primary_executor.

        Returns:
            The result of the successful execution or None if all fallbacks fail.
        """
        try:
            return self.primary_executor(*args, **kwargs)
        except Exception as e:
            print(f"Primary executor failed with error: {e}")
            if not self.secondary_executors:
                return None
            for secondary in self.secondary_executors:
                try:
                    return secondary(*args, **kwargs)
                except Exception as se:
                    print(f"Secondary executor '{secondary.__name__}' failed with error: {se}")
        return None


# Example usage
def multiply(a: int, b: int) -> int:
    """Multiply two integers."""
    return a * b


def add(a: int, b: int) -> int:
    """Add two integers."""
    return a + b


def subtract(a: int, b: int) -> int:
    """Subtract the second integer from the first."""
    return a - b

# Define fallbacks
fallback_executors = [add, subtract]

# Create an instance of FallbackExecutor with multiply as primary and add/subtract as secondary executors
executor = FallbackExecutor(multiply, fallback_executors)

# Test cases
print(executor.execute(4, 5))  # Expected: 20 (primary succeeds)
print(executor.execute(10, 3))  # Expected: 7 (addition as primary fails but secondary succeeds)
print(executor.execute(8, -2))  # Expected: 10 (subtraction as primary fails and all secondary executors fail)
```