diff --git a/src/claude_agent_sdk/_errors.py b/src/claude_agent_sdk/_errors.py index c86bf235..e3662dd5 100644 --- a/src/claude_agent_sdk/_errors.py +++ b/src/claude_agent_sdk/_errors.py @@ -17,6 +17,7 @@ class CLINotFoundError(CLIConnectionError): def __init__( self, message: str = "Claude Code not found", cli_path: str | None = None ): + self.cli_path = cli_path if cli_path: message = f"{message}: {cli_path}" super().__init__(message) diff --git a/tests/test_errors.py b/tests/test_errors.py index 9490d075..b8a854dd 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -23,6 +23,14 @@ def test_cli_not_found_error(self): error = CLINotFoundError("Claude Code not found") assert isinstance(error, ClaudeSDKError) assert "Claude Code not found" in str(error) + assert error.cli_path is None + + def test_cli_not_found_error_with_path(self): + """Test CLINotFoundError stores cli_path and includes it in the message.""" + error = CLINotFoundError("Claude Code not found", cli_path="/usr/bin/claude") + assert error.cli_path == "/usr/bin/claude" + assert "Claude Code not found" in str(error) + assert "/usr/bin/claude" in str(error) def test_connection_error(self): """Test CLIConnectionError."""