"""Create fallback_executor
Generated by Phi-Octopus Eden
2025-11-07 00:31:17.238442
"""

```python
from typing import Callable, Any


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

    Args:
        primary_func: The primary function to execute.
        fallback_funcs: A list of functions that will be tried one by one if the primary function fails.
        error_types_to_catch: Optional. A tuple of exception types to catch when executing the primary function.

    Methods:
        execute: Executes the primary function or a fallback if an error occurs.
    """

    def __init__(self, primary_func: Callable[..., Any], fallback_funcs: list[Callable[..., Any]], 
                 error_types_to_catch: tuple[type[Exception], ...] = (Exception,)):
        self.primary_func = primary_func
        self.fallback_funcs = fallback_funcs
        self.error_types_to_catch = error_types_to_catch

    def execute(self) -> Any:
        """
        Executes the primary function and if it fails due to an exception in `error_types_to_catch`,
        tries each fallback function one by one until successful or out of fallbacks.
        
        Returns:
            The result of the successfully executed function, or raises the last caught exception.

        Raises:
            The last caught exception if all functions fail.
        """
        for func in [self.primary_func] + self.fallback_funcs:
            try:
                return func()
            except self.error_types_to_catch as e:
                print(f"Error occurred: {e}, trying next fallback...")
        raise RuntimeError("All fallbacks failed.")


# Example usage
def primary_function():
    """Primary function that may fail."""
    # Simulate a failure
    1 / 0

def fallback_function1():
    """First fallback function, successful in this case."""
    return "Fallback 1 result"

def fallback_function2():
    """Second fallback function, also successful in this case."""
    return "Fallback 2 result"


if __name__ == "__main__":
    # Create a FallbackExecutor instance
    executor = FallbackExecutor(primary_function, [fallback_function1, fallback_function2])
    
    # Execute the functions with fallback support
    try:
        result = executor.execute()
        print(f"Result: {result}")
    except Exception as e:
        print(f"Failed to execute any function: {e}")
```