Documentation
¶
Index ¶
- Variables
- func ContentFilterMessage(provider, category string) string
- func FormatDiagnosticDetail(err error) string
- func StreamRetryPayload(attempt int, delay time.Duration, classified ClassifiedError) *codersdk.ChatStreamRetry
- func TerminalErrorPayload(classified ClassifiedError) *codersdk.ChatError
- func WithClassification(err error, classified ClassifiedError) error
- type ClassifiedError
Constants ¶
This section is empty.
Variables ¶
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
ContentFilterMessage is the user-facing message for a response blocked by the provider's content filter.
func FormatDiagnosticDetail ¶ added in v2.35.0
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.