commonerrors

package
v1.62.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 5 Imported by: 5

Documentation

Overview

Package commonerrors defines typical errors which can happen.

Index

Constants

View Source
const (
	TypeReasonErrorSeparator = ':'
	MultipleErrorSeparator   = '\n'
)

Variables

View Source
var (
	ErrNotImplemented     = errors.New("not implemented")
	ErrNoExtension        = errors.New("missing extension")
	ErrNoLogger           = errors.New("missing logger")
	ErrNoLoggerSource     = errors.New("missing logger source")
	ErrNoLogSource        = errors.New("missing log source")
	ErrUndefined          = errors.New("undefined")
	ErrInvalidDestination = errors.New("invalid destination")
	ErrTimeout            = errors.New("timeout")
	ErrLocked             = errors.New("locked")
	ErrStaleLock          = errors.New("stale lock")
	ErrExists             = errors.New("already exists")
	ErrNotFound           = errors.New("not found")
	ErrUnsupported        = errors.New("unsupported")
	ErrUnavailable        = errors.New("unavailable")
	ErrWrongUser          = errors.New("wrong user")
	ErrUnauthorised       = errors.New("unauthorised")
	ErrUnknown            = errors.New("unknown")
	ErrInvalid            = errors.New("invalid")
	ErrConflict           = errors.New("conflict")
	ErrMarshalling        = errors.New("unserialisable")
	ErrCancelled          = errors.New("cancelled")
	ErrEmpty              = errors.New("empty")
	ErrUnexpected         = errors.New("unexpected")
	ErrTooLarge           = errors.New("too large")
	ErrForbidden          = errors.New("forbidden")
	ErrCondition          = errors.New("failed condition")
	ErrEOF                = errors.New("end of file")
	ErrMalicious          = errors.New("suspected malicious intent")
)

List of common errors used to qualify and categorise go errors Note: if adding error types to this list, ensure mapping functions (below) are also updated.

Functions

func Any

func Any(target error, err ...error) bool

Any determines whether the target error is of the same type as any of the errors `err`

func ConvertContextError

func ConvertContextError(err error) error

ConvertContextError converts a context error into common errors.

func CorrespondTo added in v1.29.0

func CorrespondTo(target error, description ...string) bool

CorrespondTo determines whether a `target` error corresponds to a specific error described by `description` It will check whether the error contains the string in its description. It is not case-sensitive. ```code

  CorrespondTo(errors.New("feature a is not supported", "not supported") = True
```

func DeserialiseError added in v1.45.0

func DeserialiseError(text []byte) (deserialisedError, err error)

DeserialiseError unmarshals text into an error. It tries to determine the error type.

func Ignore added in v1.32.0

func Ignore(target error, ignore ...error) error

Ignore will return nil if the target error matches one of the errors to ignore

func IsEmpty added in v1.45.0

func IsEmpty(err error) bool

IsEmpty states whether an error is empty or not. An error is considered empty if it is `nil` or has no description.

func None

func None(target error, err ...error) bool

None determines whether the target error is of none of the types of the errors `err`

func SerialiseError added in v1.45.0

func SerialiseError(err error) ([]byte, error)

SerialiseError marshals an error following a certain convention: `error type: reason`.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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