aigoerr

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package aigoerr provides structured, classifiable errors for aigo engines. Agents can use IsRetryable and GetCode to make informed retry decisions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRetryable

func IsRetryable(err error) bool

IsRetryable checks the error chain for a retryable *Error. When no structured *Error is found, it falls back to IsTransientNative to detect Go-native transient errors (timeouts, network failures).

func IsTransientNative added in v0.27.0

func IsTransientNative(err error) bool

IsTransientNative reports whether err is a Go-native transient error that is safe to retry (timeout, network failure, unexpected EOF). It does NOT check for *aigoerr.Error — use IsRetryable for that.

Types

type Code

type Code int

Code classifies an error for agent retry logic.

const (
	CodeUnknown        Code = iota
	CodeInvalidInput        // 400
	CodeAuthentication      // 401, 403
	CodeQuotaExceeded       // 402
	CodeRateLimit           // 429
	CodeServerError         // 5xx
	CodeTimeout             // context deadline / timeout
	CodeUnavailable         // engine unreachable
)

func GetCode

func GetCode(err error) (Code, bool)

GetCode extracts the error Code from the chain, if present.

type Error

type Error struct {
	Code       Code
	StatusCode int
	Message    string
	Retryable  bool
	RetryAfter time.Duration
	Err        error // wrapped original
}

Error is a structured error carrying classification metadata.

func FromHTTPResponse

func FromHTTPResponse(resp *http.Response, body []byte, prefix string) *Error

FromHTTPResponse creates a classified Error from an HTTP response. prefix is prepended to the message (e.g., "newapi", "openai").

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

Jump to

Keyboard shortcuts

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