errdefs – github.com/containerd/errdefs Index | Files

package errdefs

import "github.com/containerd/errdefs"

Package errdefs defines the common errors used throughout containerd packages.

Use with fmt.Errorf to add context to an error.

To detect an error class, use the IsXXX functions to tell whether an error is of a certain type.

Index

Variables

var (
	ErrUnknown            = errUnknown{}
	ErrInvalidArgument    = errInvalidArgument{}
	ErrNotFound           = errNotFound{}
	ErrAlreadyExists      = errAlreadyExists{}
	ErrPermissionDenied   = errPermissionDenied{}
	ErrResourceExhausted  = errResourceExhausted{}
	ErrFailedPrecondition = errFailedPrecondition{}
	ErrConflict           = errConflict{}
	ErrNotModified        = errNotModified{}
	ErrAborted            = errAborted{}
	ErrOutOfRange         = errOutOfRange{}
	ErrNotImplemented     = errNotImplemented{}
	ErrInternal           = errInternal{}
	ErrUnavailable        = errUnavailable{}
	ErrDataLoss           = errDataLoss{}
	ErrUnauthenticated    = errUnauthorized{}
)

Definitions of common error types used throughout containerd. All containerd errors returned by most packages will map into one of these errors classes. Packages should return errors of these types when they want to instruct a client to take a particular action.

These errors map closely to grpc errors.

Functions

func IsAborted

func IsAborted(err error) bool

IsAborted returns true if an operation was aborted.

func IsAlreadyExists

func IsAlreadyExists(err error) bool

IsAlreadyExists returns true if the error is due to an already existing metadata item

func IsCanceled

func IsCanceled(err error) bool

IsCanceled returns true if the error is due to `context.Canceled`.

func IsConflict

func IsConflict(err error) bool

IsConflict returns true if an operation could not proceed due to a conflict.

func IsDataLoss

func IsDataLoss(err error) bool

IsDataLoss returns true if data during an operation was lost or corrupted

func IsDeadlineExceeded

func IsDeadlineExceeded(err error) bool

IsDeadlineExceeded returns true if the error is due to `context.DeadlineExceeded`.

func IsFailedPrecondition

func IsFailedPrecondition(err error) bool

IsFailedPrecondition returns true if an operation could not proceed due to the lack of a particular condition

func IsInternal

func IsInternal(err error) bool

IsInternal returns true if the error returns to an internal or system error

func IsInvalidArgument

func IsInvalidArgument(err error) bool

IsInvalidArgument returns true if the error is due to an invalid argument

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the error is due to a missing object

func IsNotImplemented

func IsNotImplemented(err error) bool

IsNotImplemented returns true if the error is due to not being implemented

func IsNotModified

func IsNotModified(err error) bool

IsNotModified returns true if an operation could not proceed due to an object not modified from a previous state.

func IsOutOfRange

func IsOutOfRange(err error) bool

IsOutOfRange returns true if an operation could not proceed due to data being out of the expected range.

func IsPermissionDenied

func IsPermissionDenied(err error) bool

IsPermissionDenied returns true if the error is due to permission denied or forbidden (403) response

func IsResourceExhausted

func IsResourceExhausted(err error) bool

IsResourceExhausted returns true if the error is due to a lack of resources or too many attempts.

func IsUnauthorized

func IsUnauthorized(err error) bool

IsUnauthorized returns true if the error indicates that the user was unauthenticated or unauthorized.

func IsUnavailable

func IsUnavailable(err error) bool

IsUnavailable returns true if the error is due to a resource being unavailable

func IsUnknown

func IsUnknown(err error) bool

IsUnknown returns true if the error is due to an unknown error, unhandled condition or unexpected response.

func Resolve

func Resolve(err error) error

Resolve returns the first error found in the error chain which matches an error defined in this package or context error. A raw, unwrapped error is returned or ErrUnknown if no matching error is found.

This is useful for determining a response code based on the outermost wrapped error rather than the original cause. For example, a not found error deep in the code may be wrapped as an invalid argument. When determining status code from Is* functions, the depth or ordering of the error is not considered.

The search order is depth first, a wrapped error returned from any part of the chain from `Unwrap() error` will be returned before any joined errors as returned by `Unwrap() []error`.

Source Files

errors.go resolve.go

Version
v1.0.0 (latest)
Published
Oct 8, 2024
Platform
js/wasm
Imports
2 packages
Last checked
now

Tools for package owners.