"""Create fallback_executor
Generated by Phi-Octopus Eden
2025-11-07 20:18:28.018073
"""

```python
from typing import Callable, Any


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

    Args:
        main_function: The primary function to execute.
        fallback_functions: A list of functions to be tried sequentially if the main function fails.
        error_types_to_catch: A tuple of types of exceptions that should trigger fallback execution.
        max_retries: Maximum number of retries including the initial attempt. Defaults to 3.

    Methods:
        run: Executes the primary function or a fallback in case of an error.
    """

    def __init__(self,
                 main_function: Callable[..., Any],
                 fallback_functions: list[Callable[..., Any]],
                 error_types_to_catch: tuple[type[Exception], ...] = (Exception,),
                 max_retries: int = 3):
        self.main_function = main_function
        self.fallback_functions = fallback_functions
        self.error_types_to_catch = error_types_to_catch
        self.max_retries = max_retries

    def run(self, *args, **kwargs) -> Any:
        """
        Executes the main function with a fallback mechanism if an exception is raised.

        Args:
            args: Positional arguments to be passed to the functions.
            kwargs: Keyword arguments to be passed to the functions.

        Returns:
            The result of the successfully executed function or None if all retries fail.
        """
        attempts = 0
        while attempts < self.max_retries:
            try:
                return self.main_function(*args, **kwargs)
            except self.error_types_to_catch as e:
                # Print error for debugging purposes
                print(f"Caught exception: {e}")
                if not self.fallback_functions:
                    raise e

                fallback = self.fallback_functions[0]
                del self.fallback_functions[0]

                attempts += 1
                continue

        return None


# Example usage
def main_function(x):
    result = 1 / x
    print(f"Main function result: {result}")
    return result


def fallback_1(x):
    result = -x * (x - 2)
    print(f"Fallback 1 result: {result}")
    return result


def fallback_2(x):
    result = "Fallback 2 was executed"
    print(f"Fallback 2 result: {result}")
    return result


# Create an instance of FallbackExecutor
executor = FallbackExecutor(main_function, [fallback_1, fallback_2])

# Run the function with some input
try:
    executor.run(0)  # This will raise a ZeroDivisionError and trigger fallbacks
except Exception as e:
    print(f"Final exception: {e}")
```