errdefs

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2018 License: Apache-2.0, CC-BY-4.0 Imports: 4 Imported by: 0

Documentation

Overview

Package errdefs defines the common errors used throughout containerd packages.

Use with errors.Wrap and error.Wrapf 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.

The functions ToGRPC and FromGRPC can be used to map server-side and client-side errors to the correct types.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknown            = errors.New("unknown") // used internally to represent a missed mapping.
	ErrInvalidArgument    = errors.New("invalid argument")
	ErrNotFound           = errors.New("not found")
	ErrAlreadyExists      = errors.New("already exists")
	ErrFailedPrecondition = errors.New("failed precondition")
	ErrUnavailable        = errors.New("unavailable")
	ErrNotImplemented     = errors.New("not implemented") // represents not supported and unimplemented
)

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.

For the most part, we just try to provide local grpc errors. Most conditions map very well to those defined by grpc.

Functions

func FromGRPC

func FromGRPC(err error) error

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

func IsAlreadyExists

func IsAlreadyExists(err error) bool

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

func IsFailedPrecondition

func IsFailedPrecondition(err error) bool

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

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 IsUnavailable

func IsUnavailable(err error) bool

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

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 errors.ToGRPC(errors.Wrapf(err, format, args...))

Types

This section is empty.

Jump to

Keyboard shortcuts

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