chaterror

package
v2.35.7 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrProviderTransportReset = xerrors.New("provider transport reset")

ErrProviderTransportReset identifies provider stream cancellations that occur while the caller-owned chat context is still alive.

Functions

func FormatDiagnosticDetail added in v2.35.0

func FormatDiagnosticDetail(err error) string

FormatDiagnosticDetail returns a bounded, single-line diagnostic string from err, suitable for surfacing to a user.

func StreamRetryPayload

func StreamRetryPayload(
	attempt int,
	delay time.Duration,
	classified ClassifiedError,
) *codersdk.ChatStreamRetry

func TerminalErrorPayload added in v2.34.0

func TerminalErrorPayload(classified ClassifiedError) *codersdk.ChatError

func WithClassification

func WithClassification(err error, classified ClassifiedError) error

WithClassification wraps err so future calls to Classify return classified instead of re-deriving it from err.Error().

Types

type ClassifiedError

type ClassifiedError struct {
	Message    string
	Detail     string
	Kind       codersdk.ChatErrorKind
	Provider   string
	Retryable  bool
	StatusCode int

	// RetryAfter is a normalized minimum retry delay derived from
	// provider response metadata when available.
	RetryAfter time.Duration

	// ChainBroken is true when the provider reported that the
	// previous_response_id (or analogous chain anchor) is no longer
	// retrievable. The chatloop retry path uses this signal to exit
	// chain mode and replay full history before the next attempt.
	// This is an internal signal; it is not surfaced as a separate
	// codersdk.ChatErrorKind so the user-visible kind set stays
	// stable.
	ChainBroken bool
}

ClassifiedError is the normalized, user-facing view of an underlying provider or runtime error.

func Classify

func Classify(err error) ClassifiedError

Classify normalizes err into a stable, user-facing payload used for retry handling, streamed terminal errors, and persisted last_error values.

func (ClassifiedError) WithProvider

func (c ClassifiedError) WithProvider(provider string) ClassifiedError

WithProvider returns a copy of the classification using an explicit provider hint. Explicit provider hints are trusted over provider names heuristically parsed from the error text.

Jump to

Keyboard shortcuts

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