vxerrors

package
v0.1.0-preview Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package errors is the typed error hierarchy returned by the SDK.

All SDK methods return errors that satisfy the standard error interface. To branch on category, use errors.As:

var authErr *vxerrors.AuthError
if errors.As(err, &authErr) {
    // re-login flow
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromHTTP

func FromHTTP(op string, status int, message, detail string) error

FromHTTP constructs the appropriate concrete error type for an HTTP response. Used by the transport layer; callers should not need this directly.

func IsRetryable

func IsRetryable(err error) bool

IsRetryable reports whether retrying the same request, possibly after backing off, is appropriate.

Types

type AuthError

type AuthError struct{ *Failure }

AuthError indicates the credential was rejected (401/403) or invalid in shape. The caller's response is to obtain a new credential — retrying with the same key will not succeed.

type Failure

type Failure struct {
	// Op is the SDK operation that failed (e.g. "cicd.Pipelines.List").
	Op string
	// HTTPStatus is the upstream HTTP status if the failure was an API call.
	HTTPStatus int
	// Message is a short, human-readable description.
	Message string
	// Detail is the unwrapped upstream error body when present.
	Detail string
	// Cause is the underlying Go error if any.
	Cause error
}

Failure is the generic error type. Every concrete typed error in this package embeds *Failure, so its Op / HTTPStatus / Cause fields are always accessible.

The type is named Failure (not Error) deliberately — embedding a struct named Error would shadow the Error() method on the outer wrapper types.

func (*Failure) Error

func (e *Failure) Error() string

func (*Failure) Unwrap

func (e *Failure) Unwrap() error

type NetworkError

type NetworkError struct{ *Failure }

NetworkError indicates the request did not reach the server (DNS, TCP, TLS, timeout). Safe to retry with backoff.

type NotFoundError

type NotFoundError struct{ *Failure }

NotFoundError indicates the resource does not exist (404).

type RateLimitError

type RateLimitError struct {
	*Failure
	RetryAfter int // seconds; 0 if not advertised
}

RateLimitError indicates the caller exceeded a quota (429). RetryAfter is the suggested wait, derived from the Retry-After header if present.

type ServerError

type ServerError struct{ *Failure }

ServerError indicates an upstream 5xx. Safe to retry with backoff.

type ValidationError

type ValidationError struct {
	*Failure
	// Fields names the offending field(s) when the server returned them.
	Fields []string
}

ValidationError indicates the request payload was malformed (400 / 422). The caller must fix the payload — retrying as-is will fail.

Jump to

Keyboard shortcuts

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