"""Create fallback_executor
Generated by Phi-Octopus Eden
2025-11-06 20:42:30.744547
"""

```python
from typing import Callable, Any

class FallbackExecutor:
    """
    A class that provides a fallback mechanism for executing functions.
    If the primary function fails, it attempts to execute a secondary function.

    :param primary_func: The main function to be executed.
    :type primary_func: Callable[..., Any]
    :param fallback_func: An optional secondary function to use as a fallback if `primary_func` raises an exception.
    :type fallback_func: Callable[..., Any] or None
    """

    def __init__(self, primary_func: Callable[..., Any], fallback_func: Callable[..., Any] = None):
        self.primary_func = primary_func
        self.fallback_func = fallback_func

    def execute(self, *args, **kwargs) -> Any:
        """
        Attempts to execute the `primary_func` with provided args and kwargs.
        If an exception is raised during execution of `primary_func`, it attempts to execute `fallback_func`.

        :param args: Positional arguments for `self.primary_func`.
        :param kwargs: Keyword arguments for `self.primary_func`.
        :return: The result of the executed function or None if both functions fail.
        """
        try:
            return self.primary_func(*args, **kwargs)
        except Exception as e:
            if self.fallback_func is not None:
                print(f"Primary function failed with exception: {e}")
                try:
                    return self.fallback_func(*args, **kwargs)
                except Exception as fallback_e:
                    print(f"Fallback function also failed with exception: {fallback_e}")
            else:
                raise e

# Example usage
def main_function(x):
    """
    A primary function that calculates the square of a number.
    :param x: An integer to be squared.
    :return: The square of `x`.
    """
    return x ** 2

def fallback_function(x):
    """
    A secondary function used as a fallback if `main_function` fails.
    :param x: An integer that will be tripled (as an alternate operation).
    :return: Triple the value of `x`.
    """
    return x * 3

# Create FallbackExecutor instance
executor = FallbackExecutor(main_function, fallback_func=fallback_function)

# Example calls to execute functions
try:
    result = executor.execute(5)
    print(f"Result from primary function: {result}")
except Exception as e:
    print(f"An error occurred during execution: {e}")

print("\nNow trying with an argument that causes the primary function to fail (will trigger fallback):")
try:
    result = executor.execute(-1)  # This should not raise, but we simulate a failure
except Exception as e:
    result = executor.execute(-1)
    print(f"Result from fallback function: {result}")
```