"""Create fallback_executor
Generated by Phi-Octopus Eden
2025-11-06 03:52:25.845499
"""

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


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

    Args:
        primary_function: The main function to be executed.
        fallback_functions: A list of functions to attempt execution if the primary function fails.
        exception_types: A tuple of exceptions that should trigger fallbacks. By default, it catches all exceptions.

    Usage Example:

    >>> def divide(a: float, b: float) -> float:
    ...     return a / b

    >>> def safe_divide(a: float, b: float) -> Optional[float]:
    ...     try:
    ...         return divide(a, b)
    ...     except ZeroDivisionError:
    ...         print("Caught division by zero")
    ...         return None
    ...
    >>> fallback_executor = FallbackExecutor(
    ...     primary_function=divide,
    ...     fallback_functions=[safe_divide],
    ...     exception_types=(ZeroDivisionError,)
    ... )
    ...
    >>> result = fallback_executor.execute(10.0, 2.0)
    >>> print(result)  # Output: 5.0
    >>> result = fallback_executor.execute(10.0, 0.0)
    >>> print(result)  # Output: Caught division by zero; None

    """

    def __init__(self,
                 primary_function: Callable[..., Any],
                 fallback_functions: Optional[list[Callable[..., Any]]] = None,
                 exception_types: tuple[type[BaseException], ...] = (Exception,)
                 ):
        self.primary_function = primary_function
        self.fallback_functions = [] if fallback_functions is None else fallback_functions
        self.exception_types = exception_types

    def execute(self, *args: Any, **kwargs: Any) -> Optional[Any]:
        try:
            return self.primary_function(*args, **kwargs)
        except self.exception_types as e:
            for fallback in self.fallback_functions:
                try:
                    return fallback(*args, **kwargs)
                except self.exception_types:
                    continue
            raise e


# Example usage of FallbackExecutor class
def multiply(a: float, b: float) -> float:
    return a * b

def safe_multiply(a: float, b: float) -> Optional[float]:
    try:
        return multiply(a, b)
    except Exception as e:
        print(f"Caught an error during multiplication: {e}")
        return None


fallback_executor = FallbackExecutor(
    primary_function=multiply,
    fallback_functions=[safe_multiply],
    exception_types=(Exception,)
)

# Test the example usage
result = fallback_executor.execute(10.0, 2.0)
print(result)  # Output: 20.0

result = fallback_executor.execute(10.0, 'invalid')  # Raises TypeError during primary function call
```