"""Create recovery_planner
Generated by Phi-Octopus Eden
2025-11-08 19:54:33.049061
"""

```python
from typing import Callable, Any


class RecoveryPlanner:
    """
    A class for creating a limited error recovery planner.
    This allows handling errors in functions by automatically retrying them with a configurable maximum number of attempts.

    Attributes:
        max_attempts (int): The maximum number of times to attempt the function before giving up.
        on_error (Callable[[Exception], Any]): A callback function that is called when an error occurs during execution.
    """

    def __init__(self, max_attempts: int = 3, on_error: Callable[[Exception], Any] = None):
        """
        Initialize the RecoveryPlanner.

        Args:
            max_attempts (int): The maximum number of times to attempt the function before giving up. Default is 3.
            on_error (Callable[[Exception], Any]): A callback function that is called when an error occurs during execution.
                If not provided, it will print the exception and continue with the next attempt.
        """
        self.max_attempts = max_attempts
        self.on_error = on_error

    def __call__(self, func: Callable) -> Callable:
        """
        Decorator method to wrap a function for error recovery.

        Args:
            func (Callable): The function to be wrapped and enhanced with error recovery.

        Returns:
            Callable: A wrapper function that handles errors.
        """

        def wrapper(*args, **kwargs):
            attempts = 0
            while attempts < self.max_attempts:
                try:
                    return func(*args, **kwargs)
                except Exception as e:
                    if self.on_error is not None:
                        self.on_error(e)
                    else:
                        print(f"Error occurred: {e}")
                    attempts += 1

        return wrapper


# Example usage
@RecoveryPlanner(max_attempts=5, on_error=lambda e: print("Custom error handling logic", e))
def risky_function():
    import random
    if random.randint(0, 2) == 1:
        raise ValueError("Simulated error")
    print("Function executed successfully")

# Simulating function calls
for _ in range(6):
    try:
        risky_function()
    except Exception as e:
        print(f"Exception caught: {e}")
```