Documentation
¶
Overview ¶
Package errors defines error types for the Claude SDK.
This package provides structured error types that wrap different failure scenarios when interacting with the Claude CLI. All error types support error unwrapping and can be checked using errors.Is, errors.As, and errors.AsType.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrClientNotConnected indicates the client is not connected. ErrClientNotConnected = errors.New("client not connected") // ErrClientAlreadyConnected indicates the client is already connected. ErrClientAlreadyConnected = errors.New("client already connected") // ErrClientClosed indicates the client has been closed and cannot be reused. ErrClientClosed = errors.New("client closed: clients are single-use, create a new one with New()") // ErrTransportNotConnected indicates the transport is not connected. ErrTransportNotConnected = errors.New("transport not connected") // ErrRequestTimeout indicates a request timed out. ErrRequestTimeout = errors.New("request timeout") // ErrControllerStopped indicates the protocol controller has stopped. ErrControllerStopped = errors.New("protocol controller stopped") // ErrStdinClosed indicates stdin was closed due to context cancellation. ErrStdinClosed = errors.New("stdin closed") // ErrOperationCancelled indicates an operation was cancelled via cancel request. ErrOperationCancelled = errors.New("operation cancelled") // ErrUnknownMessageType indicates the message type is not recognized by the SDK. // Callers should skip these messages rather than treating them as fatal. ErrUnknownMessageType = errors.New("unknown message type") // ErrSessionNotFound indicates no persisted session was found for the given session ID. ErrSessionNotFound = errors.New("session not found") )
Sentinel errors for commonly checked conditions.
Functions ¶
This section is empty.
Types ¶
type CLIConnectionError ¶
type CLIConnectionError struct {
Err error
}
CLIConnectionError indicates failure to connect to the CLI.
func (*CLIConnectionError) Error ¶
func (e *CLIConnectionError) Error() string
func (*CLIConnectionError) IsClaudeSDKError ¶
func (e *CLIConnectionError) IsClaudeSDKError() bool
IsClaudeSDKError implements ClaudeSDKError.
func (*CLIConnectionError) Unwrap ¶
func (e *CLIConnectionError) Unwrap() error
type CLIJSONDecodeError ¶
CLIJSONDecodeError indicates JSON parsing failed for CLI output. This error preserves the original raw data that failed to parse.
func (*CLIJSONDecodeError) Error ¶
func (e *CLIJSONDecodeError) Error() string
func (*CLIJSONDecodeError) IsClaudeSDKError ¶
func (e *CLIJSONDecodeError) IsClaudeSDKError() bool
IsClaudeSDKError implements ClaudeSDKError.
func (*CLIJSONDecodeError) Unwrap ¶
func (e *CLIJSONDecodeError) Unwrap() error
type CLINotFoundError ¶
type CLINotFoundError struct {
SearchedPaths []string
}
CLINotFoundError indicates the Claude CLI binary was not found.
func (*CLINotFoundError) Error ¶
func (e *CLINotFoundError) Error() string
func (*CLINotFoundError) IsClaudeSDKError ¶
func (e *CLINotFoundError) IsClaudeSDKError() bool
IsClaudeSDKError implements ClaudeSDKError.
type ClaudeSDKError ¶
ClaudeSDKError is the base interface for all SDK errors.
type MessageParseError ¶
MessageParseError indicates message parsing failed.
func (*MessageParseError) Error ¶
func (e *MessageParseError) Error() string
func (*MessageParseError) IsClaudeSDKError ¶
func (e *MessageParseError) IsClaudeSDKError() bool
IsClaudeSDKError implements ClaudeSDKError.
func (*MessageParseError) Unwrap ¶
func (e *MessageParseError) Unwrap() error
type ProcessError ¶
ProcessError indicates the CLI process failed.
func (*ProcessError) Error ¶
func (e *ProcessError) Error() string
func (*ProcessError) IsClaudeSDKError ¶
func (e *ProcessError) IsClaudeSDKError() bool
IsClaudeSDKError implements ClaudeSDKError.
func (*ProcessError) Unwrap ¶
func (e *ProcessError) Unwrap() error