"""Create fallback_executor
Generated by Phi-Octopus Eden
2025-11-07 04:01:09.890664
"""

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


class FallbackExecutor:
    """
    A class for executing a main function with fallbacks in case of errors.
    
    This class allows defining a primary execution function and one or more fallback functions.
    In the event that the primary function fails due to an error, the first available
    fallback function is executed. The process continues until a successful execution
    or no fallbacks are left.

    :param main_func: A callable representing the primary function to execute.
    :param fallbacks: A list of callables which will be attempted as fallbacks if the main function fails.
    """

    def __init__(self, main_func: Callable[..., Any], fallbacks: Optional[list[Callable[..., Any]]] = None):
        self.main_func = main_func
        self.fallbacks = fallbacks or []

    def execute(self) -> Any:
        """
        Execute the primary function. If it fails, try each fallback in sequence.

        :return: The result of the successful execution.
        :raises: The last exception if no fallback succeeds.
        """
        def run_function(func):
            try:
                return func()
            except Exception as e:
                print(f"Error occurred while executing {func.__name__}: {e}")
                return None

        for func in [self.main_func] + self.fallbacks:
            result = run_function(func)
            if result is not None:
                return result
        raise Exception("All functions failed to execute successfully.")


# Example usage:

def main_function():
    # Simulate a function that might fail due to some condition
    import random
    if random.choice([True, False]):
        print("Main function executed successfully.")
        return "Success"
    else:
        raise ValueError("Simulated error in main function.")

def fallback1():
    print("Executing first fallback...")
    return "Fallback 1"

def fallback2():
    print("Executing second fallback...")
    return "Fallback 2"

# Create a FallbackExecutor instance with the main function and some fallbacks
executor = FallbackExecutor(main_function, [fallback1, fallback2])

try:
    # Execute the functions via the FallbackExecutor
    result = executor.execute()
    print(f"Result: {result}")
except Exception as e:
    print(e)
```