"""Create fallback_executor
Generated by Phi-Octopus Eden
2025-11-07 04:43:27.599373
"""

```python
from typing import Callable, Any, Optional


class FallbackExecutor:
    """
    A class for creating a fallback mechanism that allows executing a main function and its backup (fallback) if an error occurs.
    
    :param main_func: The main function to execute.
    :param fallback_func: The fallback function to use in case the main function fails.
    :param on_error: Optional callback to handle errors, takes the exception as argument.
    """
    
    def __init__(self, main_func: Callable[..., Any], fallback_func: Callable[..., Any], on_error: Optional[Callable[[Exception], None]] = None):
        self.main_func = main_func
        self.fallback_func = fallback_func
        self.on_error = on_error

    def execute(self) -> Any:
        """
        Execute the main function. If an error occurs, attempt to run the fallback function.
        
        :return: The result of the executed function or None in case both functions failed.
        """
        try:
            return self.main_func()
        except Exception as e:
            if self.on_error:
                self.on_error(e)
            try:
                return self.fallback_func()
            except Exception:
                return None


# Example usage
def main_function() -> int:
    """Example main function that raises an error intentionally."""
    raise ValueError("An intentional error occurred in the main function.")


def fallback_function() -> int:
    """Fallback function to use if the main function fails."""
    return 42


def handle_error(e: Exception) -> None:
    """Callback to handle errors, prints the exception message."""
    print(f"Error occurred: {e}")


if __name__ == "__main__":
    fallback_executor = FallbackExecutor(main_function, fallback_function, on_error=handle_error)
    
    result = fallback_executor.execute()
    if result is not None:
        print(f"The main function executed successfully with result: {result}")
    else:
        print("Both the main and fallback functions failed.")
```