failure

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConfig              error = sentinel{/* contains filtered or unexported fields */}
	ErrValidation          error = sentinel{/* contains filtered or unexported fields */}
	ErrMetric              error = sentinel{/* contains filtered or unexported fields */}
	ErrMetricParse         error = sentinel{/* contains filtered or unexported fields */}
	ErrProviderRequest     error = sentinel{/* contains filtered or unexported fields */}
	ErrProviderAuth        error = sentinel{/* contains filtered or unexported fields */}
	ErrProviderRateLimit   error = sentinel{/* contains filtered or unexported fields */}
	ErrProviderUnavailable error = sentinel{/* contains filtered or unexported fields */}
	ErrProviderResponse    error = sentinel{/* contains filtered or unexported fields */}
	ErrProviderRefusal     error = sentinel{/* contains filtered or unexported fields */}
	ErrProviderTruncated   error = sentinel{/* contains filtered or unexported fields */}
	ErrPanic               error = sentinel{/* contains filtered or unexported fields */}
)

Functions

func Config

func Config(code Code, operation, message string, cause error) error

func FormatInvalidURL

func FormatInvalidURL(raw, detail string) string

func Metric

func Metric(code Code, message string, cause error) error

func MetricParse

func MetricParse(message string, cause error) error

func RedactedURL

func RedactedURL(raw string) string

func RetryableStatus

func RetryableStatus(code int) bool

func Validation

func Validation(code Code, operation, field, message string, cause error) error

Types

type Code

type Code string

Code is a stable machine-readable reason for a Gaugo failure.

const (
	CodeUnknown                  Code = "unknown"
	CodeConfigInvalid            Code = "config_invalid"
	CodeRunnerConfigInvalid      Code = "runner_config_invalid"
	CodeValidationInvalid        Code = "validation_invalid"
	CodeContextCanceled          Code = "context_canceled"
	CodeContextDeadline          Code = "context_deadline"
	CodeCaseInvalid              Code = "case_invalid"
	CodeRetryInvalid             Code = "retry_invalid"
	CodeMetricInvalid            Code = "metric_invalid"
	CodeMetricParse              Code = "metric_parse"
	CodeProviderConfigInvalid    Code = "provider_config_invalid"
	CodeProviderAPIKeyRequired   Code = "provider_api_key_required"
	CodeProviderHTTPRequest      Code = "provider_http_request"
	CodeProviderHTTPStatus       Code = "provider_http_status"
	CodeProviderResponseDecode   Code = "provider_response_decode"
	CodeProviderResponseInvalid  Code = "provider_response_invalid"
	CodeProviderResponseTooLarge Code = "provider_response_too_large"
	CodeProviderRefusal          Code = "provider_refusal"
	CodeProviderTruncated        Code = "provider_truncated"
	CodePanic                    Code = "panic"
)

type Error

type Error struct {
	Kind       Kind
	Code       Code
	Message    string
	Operation  string
	Field      string
	Provider   string
	Wire       string
	Model      string
	StatusCode int
	RequestID  string
	BodyBytes  int
	LimitBytes int64
	Retryable  bool
	Err        error
}

Error is Gaugo's typed operational error. It keeps a human message, structured integration metadata, and an optional wrapped cause.

func (*Error) Error

func (e *Error) Error() string

func (*Error) GaugoBodyBytes

func (e *Error) GaugoBodyBytes() int

func (*Error) GaugoErrorCode

func (e *Error) GaugoErrorCode() string

func (*Error) GaugoErrorKind

func (e *Error) GaugoErrorKind() string

func (*Error) GaugoField

func (e *Error) GaugoField() string

func (*Error) GaugoLimitBytes

func (e *Error) GaugoLimitBytes() int64

func (*Error) GaugoModel

func (e *Error) GaugoModel() string

func (*Error) GaugoOperation

func (e *Error) GaugoOperation() string

func (*Error) GaugoProvider

func (e *Error) GaugoProvider() string

func (*Error) GaugoRequestID

func (e *Error) GaugoRequestID() string

func (*Error) GaugoRetryable

func (e *Error) GaugoRetryable() bool

func (*Error) GaugoStatusCode

func (e *Error) GaugoStatusCode() int

func (*Error) GaugoWire

func (e *Error) GaugoWire() string

func (*Error) Info

func (e *Error) Info() Info

func (*Error) Is

func (e *Error) Is(target error) bool

Is lets callers use errors.Is(err, gaugo.ErrProviderRateLimit) style checks.

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Info

type Info struct {
	Kind       Kind   `json:"kind,omitempty"`
	Code       Code   `json:"code,omitempty"`
	Message    string `json:"message,omitempty"`
	Operation  string `json:"operation,omitempty"`
	Field      string `json:"field,omitempty"`
	Provider   string `json:"provider,omitempty"`
	Wire       string `json:"wire,omitempty"`
	Model      string `json:"model,omitempty"`
	StatusCode int    `json:"status_code,omitempty"`
	RequestID  string `json:"request_id,omitempty"`
	BodyBytes  int    `json:"body_bytes,omitempty"`
	LimitBytes int64  `json:"limit_bytes,omitempty"`
	Retryable  bool   `json:"retryable,omitempty"`
}

Info is a redacted, structured description of an operational failure.

func Classify

func Classify(err error) Info

type Kind

type Kind string

Kind classifies operational failures separately from low quality scores.

const (
	KindUnknown             Kind = "unknown"
	KindConfig              Kind = "config"
	KindValidation          Kind = "validation"
	KindContextCanceled     Kind = "context_canceled"
	KindContextDeadline     Kind = "context_deadline"
	KindPanic               Kind = "panic"
	KindMetric              Kind = "metric"
	KindMetricParse         Kind = "metric_parse"
	KindProviderRequest     Kind = "provider_request"
	KindProviderAuth        Kind = "provider_auth"
	KindProviderRateLimit   Kind = "provider_rate_limit"
	KindProviderUnavailable Kind = "provider_unavailable"
	KindProviderResponse    Kind = "provider_response"
	KindProviderRefusal     Kind = "provider_refusal"
	KindProviderTruncated   Kind = "provider_truncated"
)

func KindFromStatusCode

func KindFromStatusCode(code int) Kind

Jump to

Keyboard shortcuts

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