"""Create fallback_executor
Generated by Phi-Octopus Eden
2025-11-08 17:57:30.161864
"""

```python
from typing import Callable, Any


class FallbackExecutor:
    """
    A class for creating a fallback execution mechanism that tries multiple functions until one succeeds.
    
    Example Usage:
        def func1(x: int) -> int:
            return x + 5

        def func2(x: int) -> int:
            raise ValueError("Error in second function")

        try:
            result = FallbackExecutor([func1, func2], lambda error: print(f"Function failed with {error}"))
            result(10)
        except Exception as e:
            print(e)

    Args:
        functions: A list of callables to be tried sequentially.
        fallback_function: Optional. A function that takes an exception as input and can be executed if all other functions fail.

    Raises:
        The last raised exception if no function succeeds.
    """

    def __init__(self, functions: list[Callable], fallback_function: Callable[[Exception], Any] = None):
        self.functions = functions
        self.fallback_function = fallback_function

    def __call__(self, *args, **kwargs) -> Any:
        for func in self.functions:
            try:
                return func(*args, **kwargs)
            except Exception as e:
                print(f"Function {func.__name__} failed with: {e}")
        
        if self.fallback_function:
            return self.fallback_function(Exception("All functions have failed"))
        else:
            raise Exception("All functions have failed")


# Example usage
def func1(x: int) -> int:
    return x + 5

def func2(x: int) -> int:
    raise ValueError("Error in second function")

def fallback_handler(e: Exception):
    print(f"Handling exception: {e}")

try:
    result = FallbackExecutor([func1, func2], fallback_handler)
    print(result(10))
except Exception as e:
    print(e)
```