errdefs

package
v28.0.0-rc.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Overview

Package errdefs defines a set of error interfaces that packages should use for communicating classes of errors. Errors that cross the package boundary should implement one (and only one) of these interfaces.

Packages should not reference these interfaces directly, only implement them. To check if a particular error implements one of these interfaces, there are helper functions provided (e.g. `Is<SomeError>`) which can be used rather than asserting the interfaces directly. If you must assert on these interfaces, be sure to check the causal chain (`err.Cause()`).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cancelled

func Cancelled(err error) error

Cancelled creates an ErrCancelled error from the given error. It returns the error as-is if it is either nil (no error) or already implements ErrCancelled,

func Conflict

func Conflict(err error) error

Conflict creates an ErrConflict error from the given error. It returns the error as-is if it is either nil (no error) or already implements ErrConflict,

func DataLoss

func DataLoss(err error) error

DataLoss creates an ErrDataLoss error from the given error. It returns the error as-is if it is either nil (no error) or already implements ErrDataLoss,

func Deadline

func Deadline(err error) error

Deadline creates an ErrDeadline error from the given error. It returns the error as-is if it is either nil (no error) or already implements ErrDeadline,

func Forbidden

func Forbidden(err error) error

Forbidden creates an ErrForbidden error from the given error. It returns the error as-is if it is either nil (no error) or already implements ErrForbidden,

func FromContext

func FromContext(ctx context.Context) error

FromContext returns the error class from the passed in context

func FromStatusCode

func FromStatusCode(err error, statusCode int) error

FromStatusCode creates an errdef error, based on the provided HTTP status-code

func InvalidParameter

func InvalidParameter(err error) error

InvalidParameter creates an ErrInvalidParameter error from the given error. It returns the error as-is if it is either nil (no error) or already implements ErrInvalidParameter,

func IsCancelled

func IsCancelled(err error) bool

IsCancelled returns if the passed in error is an ErrCancelled.

func IsConflict

func IsConflict(err error) bool

IsConflict returns if the passed in error is an ErrConflict.

func IsContext

func IsContext(err error) bool

IsContext returns if the passed in error is due to context cancellation or deadline exceeded.

func IsDataLoss

func IsDataLoss(err error) bool

IsDataLoss returns if the passed in error is an ErrDataLoss.

func IsDeadline

func IsDeadline(err error) bool

IsDeadline returns if the passed in error is an ErrDeadline.

func IsForbidden

func IsForbidden(err error) bool

IsForbidden returns if the passed in error is an ErrForbidden.

func IsInvalidParameter

func IsInvalidParameter(err error) bool

IsInvalidParameter returns if the passed in error is an ErrInvalidParameter.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns if the passed in error is an ErrNotFound,

func IsNotImplemented

func IsNotImplemented(err error) bool

IsNotImplemented returns if the passed in error is an ErrNotImplemented.

func IsNotModified

func IsNotModified(err error) bool

IsNotModified returns if the passed in error is an ErrNotModified.

func IsSystem

func IsSystem(err error) bool

IsSystem returns if the passed in error is an ErrSystem.

func IsUnauthorized

func IsUnauthorized(err error) bool

IsUnauthorized returns if the passed in error is an ErrUnauthorized.

func IsUnavailable

func IsUnavailable(err error) bool

IsUnavailable returns if the passed in error is an ErrUnavailable.

func IsUnknown

func IsUnknown(err error) bool

IsUnknown returns if the passed in error is an ErrUnknown.

func NotFound

func NotFound(err error) error

NotFound creates an ErrNotFound error from the given error. It returns the error as-is if it is either nil (no error) or already implements ErrNotFound,

func NotImplemented

func NotImplemented(err error) error

NotImplemented creates an ErrNotImplemented error from the given error. It returns the error as-is if it is either nil (no error) or already implements ErrNotImplemented,

func NotModified

func NotModified(err error) error

NotModified creates an ErrNotModified error from the given error. It returns the error as-is if it is either nil (no error) or already implements NotModified,

func System

func System(err error) error

System creates an ErrSystem error from the given error. It returns the error as-is if it is either nil (no error) or already implements ErrSystem,

func Unauthorized

func Unauthorized(err error) error

Unauthorized creates an ErrUnauthorized error from the given error. It returns the error as-is if it is either nil (no error) or already implements ErrUnauthorized,

func Unavailable

func Unavailable(err error) error

Unavailable creates an ErrUnavailable error from the given error. It returns the error as-is if it is either nil (no error) or already implements ErrUnavailable,

func Unknown

func Unknown(err error) error

Unknown creates an ErrUnknown error from the given error. It returns the error as-is if it is either nil (no error) or already implements ErrUnknown,

Types

type ErrCancelled

type ErrCancelled interface {
	Cancelled()
}

ErrCancelled signals that the action was cancelled.

type ErrConflict

type ErrConflict interface {
	Conflict()
}

ErrConflict signals that some internal state conflicts with the requested action and can't be performed. A change in state should be able to clear this error.

type ErrDataLoss

type ErrDataLoss interface {
	DataLoss()
}

ErrDataLoss indicates that data was lost or there is data corruption.

type ErrDeadline

type ErrDeadline interface {
	DeadlineExceeded()
}

ErrDeadline signals that the deadline was reached before the action completed.

type ErrForbidden

type ErrForbidden interface {
	Forbidden()
}

ErrForbidden signals that the requested action cannot be performed under any circumstances. When a ErrForbidden is returned, the caller should never retry the action.

type ErrInvalidParameter

type ErrInvalidParameter interface {
	InvalidParameter()
}

ErrInvalidParameter signals that the user input is invalid

type ErrNotFound

type ErrNotFound interface {
	NotFound()
}

ErrNotFound signals that the requested object doesn't exist

type ErrNotImplemented

type ErrNotImplemented interface {
	NotImplemented()
}

ErrNotImplemented signals that the requested action/feature is not implemented on the system as configured.

type ErrNotModified

type ErrNotModified interface {
	NotModified()
}

ErrNotModified signals that an action can't be performed because it's already in the desired state

type ErrSystem

type ErrSystem interface {
	System()
}

ErrSystem signals that some internal error occurred. An example of this would be a failed mount request.

type ErrUnauthorized

type ErrUnauthorized interface {
	Unauthorized()
}

ErrUnauthorized is used to signify that the user is not authorized to perform a specific action

type ErrUnavailable

type ErrUnavailable interface {
	Unavailable()
}

ErrUnavailable signals that the requested action/subsystem is not available.

type ErrUnknown

type ErrUnknown interface {
	Unknown()
}

ErrUnknown signals that the kind of error that occurred is not known.

Jump to

Keyboard shortcuts

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