errors

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package errors defines error types for the Codex SDK.

This package provides structured error types that wrap different failure scenarios when interacting with the Codex CLI. All error types support error unwrapping and can be checked using errors.Is and errors.As.

Index

Constants

This section is empty.

Variables

View Source
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")

	// ErrUnsupportedOption indicates an option is not supported by the selected backend.
	ErrUnsupportedOption = errors.New("unsupported option")

	// ErrUnsupportedControlRequest indicates a control request subtype is not supported.
	ErrUnsupportedControlRequest = errors.New("unsupported control request")
)

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) IsCodexSDKError

func (e *CLIConnectionError) IsCodexSDKError() bool

IsCodexSDKError implements CodexSDKError.

func (*CLIConnectionError) Unwrap

func (e *CLIConnectionError) Unwrap() error

type CLIJSONDecodeError

type CLIJSONDecodeError struct {
	RawData string
	Err     error
}

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) IsCodexSDKError

func (e *CLIJSONDecodeError) IsCodexSDKError() bool

IsCodexSDKError implements CodexSDKError.

func (*CLIJSONDecodeError) Unwrap

func (e *CLIJSONDecodeError) Unwrap() error

type CLINotFoundError

type CLINotFoundError struct {
	SearchedPaths []string
}

CLINotFoundError indicates the Codex CLI binary was not found.

func (*CLINotFoundError) Error

func (e *CLINotFoundError) Error() string

func (*CLINotFoundError) IsCodexSDKError

func (e *CLINotFoundError) IsCodexSDKError() bool

IsCodexSDKError implements CodexSDKError.

type CodexSDKError

type CodexSDKError interface {
	error
	IsCodexSDKError() bool
}

CodexSDKError is the base interface for all SDK errors.

type MessageParseError

type MessageParseError struct {
	Message string
	Err     error
	Data    map[string]any
}

MessageParseError indicates message parsing failed.

func (*MessageParseError) Error

func (e *MessageParseError) Error() string

func (*MessageParseError) IsCodexSDKError

func (e *MessageParseError) IsCodexSDKError() bool

IsCodexSDKError implements CodexSDKError.

func (*MessageParseError) Unwrap

func (e *MessageParseError) Unwrap() error

type ProcessError

type ProcessError struct {
	ExitCode int
	Stderr   string
	Err      error
}

ProcessError indicates the CLI process failed.

func (*ProcessError) Error

func (e *ProcessError) Error() string

func (*ProcessError) IsCodexSDKError

func (e *ProcessError) IsCodexSDKError() bool

IsCodexSDKError implements CodexSDKError.

func (*ProcessError) Unwrap

func (e *ProcessError) Unwrap() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL