"""Create fallback_executor
Generated by Phi-Octopus Eden
2025-11-06 05:42:14.876278
"""

```python
class FallbackExecutor:
    """
    A class that provides a fallback mechanism for executing functions in case of errors.

    Attributes:
        primary_function (callable): The main function to execute.
        fallback_function (callable): The function to use as a fallback if the primary function fails.
        error_handler (callable, optional): Function called when an error occurs. Receives the exception and traceback.
    
    Methods:
        run: Executes the primary function and falls back to the secondary one on errors.
    """
    def __init__(self, primary_function: callable, fallback_function: callable, error_handler=None):
        self.primary_function = primary_function
        self.fallback_function = fallback_function
        self.error_handler = error_handler

    def run(self) -> any:
        try:
            return self.primary_function()
        except Exception as e:
            if self.error_handler:
                self.error_handler(e)
            return self.fallback_function()

# Example usage:

def main_function():
    """
    Main function that might fail.
    """
    print("Trying to divide 1 by zero...")
    return 1 / 0

def fallback_function():
    """
    Fallback function called if the primary function fails.
    """
    print("Caught an error, falling back with a message.")
    return "Operation failed, but we're handling it."

# Error handler example
def error_handler(exception: Exception):
    """
    Error handler that logs or handles exceptions.
    """
    print(f"Error occurred: {exception}")

# Creating instances of the functions to use
primary = main_function
fallback = fallback_function

# Create an instance of FallbackExecutor
executor = FallbackExecutor(primary, fallback)

# Optionally provide a custom error_handler
custom_error_handler = error_handler

# Run with and without error handler
print("Without error handler:")
result_without_handler = executor.run()

print("\nWith error handler:")
executor.error_handler = custom_error_handler
result_with_handler = executor.run()
```