cipderr

package
v0.0.0-...-40928ac Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Overview

Package cipderr contains an enumeration with possible CIPD error categories.

Index

Constants

This section is empty.

Variables

View Source
var Tag = errtag.Make("cipderr.Code+details", CodeDetails{})

Functions

func AttachDetails

func AttachDetails(err *error, d Details)

AttachDetails attaches details to an error, preserving its code.

Overrides any previous details. Does nothing if `err` is nil.

Types

type Code

type Code string

Code is returned as part of JSON output by CIPD CLI.

It as an enumeration with broad categories of possible errors.

const (
	// Authentication or authorization error when contacting the backend.
	Auth Code = "auth_error"
	// An error doing local I/O (i.e. writing or reading files).
	IO Code = "io_error"
	// An IO error reading or writing from CIPD CAS.
	CAS Code = "cas_error"
	// An incorrectly formatted version name, instance ID, etc.
	BadArgument Code = "bad_argument_error"
	// A requested package is missing or its version can't be resolved.
	InvalidVersion Code = "invalid_version_error"
	// An error getting a response from the backend.
	BackendUnavailable Code = "backend_unavailable_error"
	// A generic fatal RPC error, e.g. violation of some precodition.
	RPC Code = "rpc_error"
	// Something (e.g. a resolved pins file) needs to be regenerated.
	Stale Code = "stale_error"
	// A hash of downloaded file doesn't match the expected value.
	HashMismatch Code = "hash_mismatch_error"
	// The admission plugin forbid installation of a package.
	NotAdmitted Code = "not_admitted_error"
	// A timeout of some sort.
	Timeout Code = "timeout_error"
	// Unrecognized (possibly transient) error.
	Unknown Code = "unknown_error"
)

func ToCode

func ToCode(err error) Code

ToCode examines a CIPD error to get a representative error code.

func (Code) Apply

func (c Code) Apply(err error) error

Apply ensures that ToCode(err) will return `c`.

func (Code) GenerateErrorTagValue

func (c Code) GenerateErrorTagValue() (key, value any)

GenerateErrorTagValue allows Code to be used directly with errors.Annotate(...).Tag.

func (Code) WithDetails

func (c Code) WithDetails(d Details) CodeDetails

WithDetails returns a error tag that attaches this code together with some details.

type CodeDetails

type CodeDetails struct {
	Code    Code
	Details *Details
}

func (CodeDetails) Apply

func (c CodeDetails) Apply(err error) error

func (CodeDetails) GenerateErrorTagValue

func (c CodeDetails) GenerateErrorTagValue() (key, value any)

type Details

type Details struct {
	Package string `json:"package,omitempty"`
	Version string `json:"version,omitempty"`
	Subdir  string `json:"subdir,omitempty"`
}

Details can be optionally attached to an error.

func ToDetails

func ToDetails(err error) *Details

ToDetails extracts error details, if available.

Jump to

Keyboard shortcuts

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