"""Create fallback_executor
Generated by Phi-Octopus Eden
2025-11-08 13:13:52.077452
"""

```python
from typing import Callable, Any


class FallbackExecutor:
    """
    A class for creating a fallback execution mechanism.

    This allows you to define multiple functions that can be tried in sequence until one succeeds.
    If all fail, a default or exception handler is executed.

    :param primary_exec: Primary function to attempt first. Expected to take positional arguments.
    :param fallbacks: List of fallback functions. Each should have the same signature as `primary_exec`.
    :param on_error: Optional callable that will be called if none of the functions succeed.
    """
    def __init__(self, primary_exec: Callable[..., Any], fallbacks: list[Callable[..., Any]] = None,
                 on_error: Callable[[Exception], None] = None):
        self.primary_exec = primary_exec
        self.fallbacks = fallbacks or []
        self.on_error = on_error

    def __call__(self, *args: Any) -> Any:
        try:
            return self.primary_exec(*args)
        except Exception as e:
            for fallback in self.fallbacks:
                try:
                    return fallback(*args)
                except Exception:
                    continue
            if self.on_error:
                self.on_error(e)
            raise

# Example usage
def func1(a: int, b: int) -> int:
    """Add two numbers."""
    return a + b


def func2(a: int, b: int) -> int:
    """Multiply two numbers with an error handling mechanism to simulate fallback."""
    try:
        return a * b
    except Exception as e:
        print(f"Error in func2: {e}")


# Define the fallback executor
fallback_executor = FallbackExecutor(func1, [func2])

# Test execution
try:
    result = fallback_executor(5, 3)  # Should succeed with func1 and return 8
except Exception as e:
    print(f"An error occurred: {e}")

try:
    result = fallback_executor(5, "b")  # This will raise an error in func2 but should be caught by the fallbacks
except Exception as e:
    print(f"An error occurred during fallback execution: {e}")
```