package errdefs

import "github.com/containerd/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            = errdefs.ErrUnknown
	ErrInvalidArgument    = errdefs.ErrInvalidArgument
	ErrNotFound           = errdefs.ErrNotFound
	ErrAlreadyExists      = errdefs.ErrAlreadyExists
	ErrPermissionDenied   = errdefs.ErrPermissionDenied
	ErrResourceExhausted  = errdefs.ErrResourceExhausted
	ErrFailedPrecondition = errdefs.ErrFailedPrecondition
	ErrConflict           = errdefs.ErrConflict
	ErrNotModified        = errdefs.ErrNotModified
	ErrAborted            = errdefs.ErrAborted
	ErrOutOfRange         = errdefs.ErrOutOfRange
	ErrNotImplemented     = errdefs.ErrNotImplemented
	ErrInternal           = errdefs.ErrInternal
	ErrUnavailable        = errdefs.ErrUnavailable
	ErrDataLoss           = errdefs.ErrDataLoss
	ErrUnauthenticated    = errdefs.ErrUnauthenticated

	IsCanceled           = errdefs.IsCanceled
	IsUnknown            = errdefs.IsUnknown
	IsInvalidArgument    = errdefs.IsInvalidArgument
	IsDeadlineExceeded   = errdefs.IsDeadlineExceeded
	IsNotFound           = errdefs.IsNotFound
	IsAlreadyExists      = errdefs.IsAlreadyExists
	IsPermissionDenied   = errdefs.IsPermissionDenied
	IsResourceExhausted  = errdefs.IsResourceExhausted
	IsFailedPrecondition = errdefs.IsFailedPrecondition
	IsConflict           = errdefs.IsConflict
	IsNotModified        = errdefs.IsNotModified
	IsAborted            = errdefs.IsAborted
	IsOutOfRange         = errdefs.IsOutOfRange
	IsNotImplemented     = errdefs.IsNotImplemented
	IsInternal           = errdefs.IsInternal
	IsUnavailable        = errdefs.IsUnavailable
	IsDataLoss           = errdefs.IsDataLoss
	IsUnauthorized       = errdefs.IsUnauthorized
)

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 FromGRPC

func FromGRPC(err error) error

FromGRPC returns the underlying error from a grpc service based on the grpc error code

func ToGRPC

func ToGRPC(err error) error

ToGRPC will attempt to map the backend containerd error into a grpc error, using the original error message as a description.

Further information may be extracted from certain errors depending on their type.

If the error is unmapped, the original error will be returned to be handled by the regular grpc error handling stack.

func ToGRPCf

func ToGRPCf(err error, format string, args ...interface{}) error

ToGRPCf maps the error to grpc error codes, assembling the formatting string and combining it with the target error string.

This is equivalent to errdefs.ToGRPC(fmt.Errorf("%s: %w", fmt.Sprintf(format, args...), err))

Source Files

errors.go grpc.go

Version
v1.7.27 (latest)
Published
Mar 17, 2025
Platform
linux/amd64
Imports
6 packages
Last checked
21 hours ago

Tools for package owners.