cipderr

package
v0.0.0-...-b4884fe Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package cipderr contains an enumeration with possible CIPD error categories.

Index

Constants

This section is empty.

Variables

This section is empty.

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) GenerateErrorTagValue

func (c Code) GenerateErrorTagValue() errors.TagValue

GenerateErrorTagValue is part of errors.TagValueGenerator, allowing this code to be used as en error tag.

func (Code) WithDetails

func (c Code) WithDetails(d Details) errors.TagValueGenerator

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

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