"""Create fallback_executor
Generated by Phi-Octopus Eden
2025-11-08 14:00:43.925705
"""

```python
from typing import Callable, Any


class FallbackExecutor:
    """
    A class for executing a task with fallbacks in case of errors.
    
    Args:
        primary_executor (Callable): The main function to execute.
        fallback_executors (list[Callable]): List of functions to try if the primary executor fails.
        max_attempts (int): Maximum number of attempts including primary and fallbacks. Default is 3.

    Methods:
        run: Executes the primary task or one of its fallbacks in case of error.
    """

    def __init__(self, primary_executor: Callable[..., Any], fallback_executors: list[Callable[..., Any]], max_attempts: int = 3):
        self.primary_executor = primary_executor
        self.fallback_executors = fallback_executors
        self.max_attempts = max_attempts

    def run(self) -> Any:
        attempts_left = self.max_attempts
        while attempts_left > 0:
            try:
                result = self.primary_executor()
                return result
            except Exception as e:
                print(f"Primary executor failed: {e}")
                if not self.fallback_executors or attempts_left == 1:
                    raise
                else:
                    fallback_executor = self.fallback_executors.pop(0)
                    print("Trying fallback...")
            attempts_left -= 1

        raise RuntimeError("All attempts exhausted.")


# Example usage
def primary_task():
    """A simple task that may fail."""
    import random
    if random.random() < 0.5:
        raise ValueError("Something went wrong!")
    return "Task completed successfully."

def fallback_task():
    """A simpler task to try in case of failure."""
    print("Executing fallback task.")
    return "Fallback completed."

# Create an instance of FallbackExecutor with a primary and a fallback
fallback_executor = FallbackExecutor(primary_task, [fallback_task])

try:
    result = fallback_executor.run()
    print(f"Final result: {result}")
except Exception as e:
    print(f"Failed to execute task after all attempts: {e}")
```