errhint

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package errhint classifies provider/model failures into a few user-actionable categories and turns them into a one-line "next step" hint.

Provider errors already arrive with a classified string prefix from providerio.ClassifiedError ("auth error:", "rate limit error:", …); lower-level failures (DNS, TLS, timeouts, context-length) arrive as raw driver or library messages. Classify matches both so the interactive error row (TUI) and the `zero exec` provider-error path (CLI) can append one concrete next step instead of dumping an identical red blob for every failure mode.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CLIHint

func CLIHint(err error) string

CLIHint returns a one-line hint referencing `zero …` subcommands, or "" when the category is Unknown. Meant for the non-interactive `zero exec` error path, where slash commands don't apply.

func HasStatusCode

func HasStatusCode(haystack string, codes ...string) bool

HasStatusCode reports whether haystack contains any of the given HTTP status codes as a standalone number — not embedded in a longer digit run like "completed in 4290ms" or "request id 14015". Exported so other packages (e.g. the reconnect classifier) can gate on a status code without re-implementing the digit-boundary check.

func TUIHint

func TUIHint(err error) string

TUIHint returns a one-line hint referencing interactive slash commands, or "" when the category is Unknown. Meant to sit under the raw error in the live error row.

Types

type Category

type Category int

Category buckets a provider/model failure into a small set of classes that each map to a distinct recovery action.

const (
	// Unknown means the error didn't match any known signature; callers should
	// emit no hint rather than guess.
	Unknown Category = iota
	Auth
	RateLimit
	Connectivity
	ModelNotFound
	ContextOverflow
)

func Classify

func Classify(err error) Category

Classify buckets err by scanning its message for known signatures. It is a deliberately conservative string heuristic — the provider layer has already discarded the numeric HTTP status by the time the error reaches a UI surface, so the message is all we have. It first gates on a provider-origin marker (see providerMarkers) so local failures never draw a provider hint, then sub-classifies. Order matters: more specific signatures are tested before broader ones (e.g. "context length" as overflow before the generic "timeout" as connectivity).

Jump to

Keyboard shortcuts

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