errors

package module
v1.19.3 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: GPL-3.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCanceledf = NewErrorf[ErrCanceled]

ErrCanceledf is a convience function for producing ErrCanceled.

View Source
var ErrInvalidf = NewErrorf[ErrInvalid]

ErrInvalidf is a convience function for producing ErrInvalid.

View Source
var ErrNotFoundf = NewErrorf[ErrNotFound]

ErrNotFoundf is a convience function for producing ErrNotFound.

View Source
var ErrUnauthenticatedf = NewErrorf[ErrUnauthenticated]

ErrUnauthenticatedf is a convience function for producing ErrUnauthenticated.

Functions

func As

func As[E error](err error) (e E, _ bool)

As is a utility for one-lining errors.As statements. e.g. cerr, match := errors.As[MyCustomError](err).

func AsMatch

func AsMatch[E error](err error) (match bool)

AsMatch is the same as As but it returns just a boolean to represent whether or not the wrapped type matches the type parameter.

func EmptyFieldError

func EmptyFieldError(field string) error

EmptyFieldError creates an ErrInvalidField for an empty field

func InvalidFieldError

func InvalidFieldError(field, reason string) error

InvalidFieldError creates an ErrInvalidField for a specific field and reason

func New

func New(s string) error

New creates a new error with errors.New

func NewErrorf

func NewErrorf[E StringError](format string, args ...any) error

NewErrorf is a generic utility for formatting a string into a target error type E.

Types

type ErrCanceled

type ErrCanceled string

ErrCanceled is returned when an operation has been prematurely canceled by the requester.

func (ErrCanceled) Error

func (e ErrCanceled) Error() string

type ErrInvalid

type ErrInvalid string

ErrInvalid represents an invalid error

func (ErrInvalid) Error

func (e ErrInvalid) Error() string

type ErrNotFound

type ErrNotFound string

ErrNotFound represents a not found error

func (ErrNotFound) Error

func (e ErrNotFound) Error() string

type ErrUnauthenticated

type ErrUnauthenticated string

ErrUnauthenticated is returned when an operation is attempted by an unauthenticated client in an authenticated context.

func (ErrUnauthenticated) Error

func (e ErrUnauthenticated) Error() string

Error() returns the underlying string of the error.

type ErrValidation

type ErrValidation struct {
	// contains filtered or unexported fields
}

ErrValidation is a validation error for a specific field and reason

func (ErrValidation) Error

func (e ErrValidation) Error() string

type StringError

type StringError interface {
	error
	~string
}

StringError is any error that also happens to have an underlying type of string.

Jump to

Keyboard shortcuts

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