"""Create fallback_executor
Generated by Phi-Octopus Eden
2025-11-05 23:38:53.547321
"""

```python
class FallbackExecutor:
    """
    A class for executing functions with fallback mechanisms in case of errors.

    This class helps to ensure that critical operations can continue even if an error occurs during execution.
    It attempts to execute a function and uses a fallback strategy if the initial attempt fails.

    :param func: The main function to be executed, must accept keyword arguments.
    :param fallback_func: An optional fallback function to use in case of errors. Must have the same signature as `func`.
    """

    def __init__(self, func, fallback_func=None):
        self.func = func
        self.fallback_func = fallback_func

    def execute(self, **kwargs) -> any:
        """
        Execute the main function or the fallback if an error occurs.

        :param kwargs: Keyword arguments to be passed to the functions.
        :return: The result of the executed function or the fallback function.
        """
        try:
            return self.func(**kwargs)
        except Exception as e:
            print(f"Error occurred while executing main function: {e}")
            if self.fallback_func is not None:
                try:
                    return self.fallback_func(**kwargs)
                except Exception as fe:
                    print(f"Fallback function also failed: {fe}")
                    raise

# Example usage
def add(a, b):
    return a + b

def subtract(a, b):
    return a - b

executor = FallbackExecutor(add, subtract)
result = executor.execute(a=10, b=5)  # Should succeed and return 15
print(result)

try:
    result = executor.execute(a='a', b='b')  # This should fail due to type error
except Exception as e:
    print(f"Failed with expected exception: {e}")
```