chaterror

package
v2.33.3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package chaterror classifies provider/runtime failures into stable, user-facing chat error payloads.

Index

Constants

View Source
const (
	KindOverloaded     = "overloaded"
	KindRateLimit      = "rate_limit"
	KindTimeout        = "timeout"
	KindStartupTimeout = "startup_timeout"
	KindAuth           = "auth"
	KindConfig         = "config"
	KindGeneric        = "generic"
)

Variables

This section is empty.

Functions

func StreamErrorPayload

func StreamErrorPayload(classified ClassifiedError) *codersdk.ChatStreamError

func StreamRetryPayload

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

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       string
	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