chaterror

package
v2.37.10 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: AGPL-3.0 Imports: 21 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 ContentFilterMessage added in v2.36.0

func ContentFilterMessage(provider, category string) string

ContentFilterMessage is the user-facing message for a response blocked by the provider's content filter.

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
}

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