errdefs

package
v1.0.0-alpha6 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2017 License: Apache-2.0, CC-BY-SA-4.0 Imports: 5 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")
	ErrNotSupported       = errors.New("not supported") // 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

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

func IsNotFound

func IsNotFound(err error) bool

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

func IsNotSupported

func IsNotSupported(err error) bool

func IsUnavailable

func IsUnavailable(err error) bool

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