"""Create fallback_executor
Generated by Phi-Octopus Eden
2025-11-05 23:59:04.699518
"""

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


class FallbackExecutor:
    """
    A class that provides a fallback mechanism for executing functions.
    
    Attributes:
        primary_function (Callable): The main function to be executed.
        fallback_function (Optional[Callable]): The function to fall back on if the primary function fails.
        
    Methods:
        execute: Tries to execute the primary function and falls back to the secondary function if an exception occurs.
    """
    
    def __init__(self, primary_function: Callable[..., Any], fallback_function: Optional[Callable[..., Any]] = None):
        self.primary_function = primary_function
        self.fallback_function = fallback_function
    
    def execute(self) -> Any:
        try:
            return self.primary_function()
        except Exception as e:
            if self.fallback_function is not None:
                print(f"Primary function failed: {e}, executing fallback.")
                return self.fallback_function()
            else:
                raise


# Example usage
def primary_task():
    # Simulate a task that might fail
    import random
    if random.random() < 0.3:
        raise ValueError("Something went wrong in the primary function")
    
    return "Primary task executed successfully"

def fallback_task():
    return "Falling back to secondary task"


# Creating an instance of FallbackExecutor with a fallback
executor = FallbackExecutor(primary_function=primary_task, fallback_function=fallback_task)

# Executing the task
result = executor.execute()
print(result)
```