errors

package
v0.0.0-...-83140b1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package errors defines the error type and functions used by asynq and its internal packages.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoProcessableTask indicates that there are no tasks ready to be processed.
	ErrNoProcessableTask = errors.New("no tasks are ready for processing")

	// ErrDuplicateTask indicates that another task with the same unique key holds the uniqueness lock.
	ErrDuplicateTask = errors.New("task already exists")

	// ErrTaskIdConflict indicates that another task with the same task ID already exist
	ErrTaskIdConflict = errors.New("task id conflicts with another task")
)

Functions

func As

func As(err error, target interface{}) bool

As finds the first error in err's chain that matches target, and if so, sets target to that error value and returns true. Otherwise, it returns false.

This function is the errors.As function from the standard library (https://golang.org/pkg/errors/#As). It is exported from this package for import convenience.

func E

func E(args ...interface{}) error

E builds an error value from its arguments. There must be at least one argument or E panics. The type of each argument determines its meaning. If more than one argument of a given type is presented, only the last one is recorded.

The types are:

errors.Op
	The operation being performed, usually the method
	being invoked (Get, Put, etc.).
errors.Code
	The canonical error code, such as NOT_FOUND.
string
	Treated as an error message and assigned to the
	Err field after a call to errors.New.
error
	The underlying error that triggered this one.

If the error is printed, only those items that have been set to non-zero values will appear in the result.

func Is

func Is(err, target error) bool

Is reports whether any error in err's chain matches target.

This function is the errors.Is function from the standard library (https://golang.org/pkg/errors/#Is). It is exported from this package for import convenience.

func IsPanicError

func IsPanicError(err error) bool

IsPanicError reports whether any error in err's chain is of type PanicError.

func IsQueueNotEmpty

func IsQueueNotEmpty(err error) bool

IsQueueNotEmpty reports whether any error in err's chain is of type QueueNotEmptyError.

func IsQueueNotFound

func IsQueueNotFound(err error) bool

IsQueueNotFound reports whether any error in err's chain is of type QueueNotFoundError.

func IsRedisCommandError

func IsRedisCommandError(err error) bool

IsRedisCommandError reports whether any error in err's chain is of type RedisCommandError.

func IsTaskAlreadyArchived

func IsTaskAlreadyArchived(err error) bool

IsTaskAlreadyArchived reports whether any error in err's chain is of type TaskAlreadyArchivedError.

func IsTaskNotFound

func IsTaskNotFound(err error) bool

IsTaskNotFound reports whether any error in err's chain is of type TaskNotFoundError.

func New

func New(text string) error

New returns an error that formats as the given text. Each call to New returns a distinct error value even if the text is identical.

This function is the errors.New function from the standard library (https://golang.org/pkg/errors/#New). It is exported from this package for import convenience.

func Unwrap

func Unwrap(err error) error

Unwrap returns the result of calling the Unwrap method on err, if err's type contains an Unwrap method returning error. Otherwise, Unwrap returns nil.

This function is the errors.Unwrap function from the standard library (https://golang.org/pkg/errors/#Unwrap). It is exported from this package for import convenience.

Types

type Code

type Code uint8

Code defines the canonical error code.

const (
	Unspecified Code = iota
	NotFound
	FailedPrecondition
	Internal
	AlreadyExists
	Unknown
)

List of canonical error codes.

func CanonicalCode

func CanonicalCode(err error) Code

CanonicalCode returns the canonical code of the given error if one is present. Otherwise it returns Unspecified.

func (Code) String

func (c Code) String() string

type Error

type Error struct {
	Code Code
	Op   Op
	Err  error
}

Error is the type that implements the error interface. It contains a number of fields, each of different type. An Error value may leave some values unset.

func (*Error) DebugString

func (e *Error) DebugString() string

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Op

type Op string

Op describes an operation, usually as the package and method, such as "rdb.Enqueue".

type PanicError

type PanicError struct {
	ErrMsg string
}

PanicError defines an error when occurred a panic error.

func (*PanicError) Error

func (e *PanicError) Error() string

type QueueNotEmptyError

type QueueNotEmptyError struct {
	Queue string // queue name
}

QueueNotEmptyError indicates that the given queue is not empty.

func (*QueueNotEmptyError) Error

func (e *QueueNotEmptyError) Error() string

type QueueNotFoundError

type QueueNotFoundError struct {
	Queue string // queue name
}

QueueNotFoundError indicates that a queue with the given name does not exist.

func (*QueueNotFoundError) Error

func (e *QueueNotFoundError) Error() string

type RedisCommandError

type RedisCommandError struct {
	Command string // redis command (e.g. LRANGE, ZADD, etc)
	Err     error  // underlying error
}

RedisCommandError indicates that the given redis command returned error.

func (*RedisCommandError) Error

func (e *RedisCommandError) Error() string

func (*RedisCommandError) Unwrap

func (e *RedisCommandError) Unwrap() error

type TaskAlreadyArchivedError

type TaskAlreadyArchivedError struct {
	Queue string // queue name
	ID    string // task id
}

TaskAlreadyArchivedError indicates that the task in question is already archived.

func (*TaskAlreadyArchivedError) Error

func (e *TaskAlreadyArchivedError) Error() string

type TaskNotFoundError

type TaskNotFoundError struct {
	Queue string // queue name
	ID    string // task id
}

TaskNotFoundError indicates that a task with the given ID does not exist in the given queue.

func (*TaskNotFoundError) Error

func (e *TaskNotFoundError) Error() string

Jump to

Keyboard shortcuts

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