xerrors

package
v0.48.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: MIT Imports: 4 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound         = New("not-found", "not found for", http.StatusNotFound)
	ErrDuplicate        = New("duplicate", "duplicate", http.StatusConflict)
	ErrFoundMany        = New("found-many", "found many but one expected", http.StatusConflict)
	ErrTypeAssertion    = New("invalid-type", "type assertion failed", http.StatusInternalServerError)
	ErrUnknown          = New("unknown", "unknown error found", http.StatusInternalServerError)
	ErrInvalidArgument  = New("invalid-argument", "invalid argument", http.StatusBadRequest)
	ErrInvalidState     = New("invalid-state", "invalid state", http.StatusPreconditionFailed)
	ErrClientCanceled   = New("cancelled", "client cancelled", 460)
	ErrTimeout          = New("timeout", "timeout", http.StatusGatewayTimeout)
	ErrGateway          = New("gateway", "gateway", http.StatusBadGateway)
	ErrUnauthorized     = New("unauthorized", "user did not provided credentials", http.StatusUnauthorized)  // Not authenticated,
	ErrForbidden        = New("forbidden", "user is not allowed to perform operation", http.StatusForbidden) // Not enough permissions
	ErrInvalidEventType = New("invalid-event-type", "invalid event type", http.StatusInternalServerError)
	ErrConditionNotMet  = New("condition-not-met", "condition not met", http.StatusPreconditionFailed)
)

Functions

func EnsureHasKey

func EnsureHasKey[K comparable, V any](value map[K]V, key K, format string, args ...any)

EnsureHasKey panics if the given map does not contain the given key.

func EnsureNotEmpty

func EnsureNotEmpty(pointer any, format string, args ...any)

EnsureNotEmpty panics if the given pointer is nil, or value is empty string, or numeric 0.

func FromHttpStatus added in v0.33.0

func FromHttpStatus(status int) error

func IsNotFound

func IsNotFound(err error) bool

func New added in v0.31.0

func New(code string, msg string, httpStatus int) error

func NewCancellationError

func NewCancellationError(entity string, keyFmt string, args ...interface{}) error

func NewConditionNotMetError added in v0.28.0

func NewConditionNotMetError(entity string, keyFmt string, args ...interface{}) error

func NewDuplicateError

func NewDuplicateError(entity string, details string, keyFmt string, args ...interface{}) error

func NewForbiddenError

func NewForbiddenError(entity string, keyFmt string, args ...interface{}) error

func NewFoundManyError

func NewFoundManyError(entity string, keyFmt string, args ...interface{}) error

func NewGatewayError

func NewGatewayError(entity string, keyFmt string, args ...interface{}) error

func NewInvalidArgumentError

func NewInvalidArgumentError(entity string, keyFmt string, args ...interface{}) error

func NewInvalidEventTypeError

func NewInvalidEventTypeError(entity string, keyFmt string, args ...interface{}) error

func NewInvalidStateError

func NewInvalidStateError(entity string, keyFmt string, args ...interface{}) error

func NewNotFoundError

func NewNotFoundError(entity string, keyFmt string, args ...interface{}) error

func NewTimeoutError

func NewTimeoutError(entity string, keyFmt string, args ...interface{}) error

func NewTypeAssertionError

func NewTypeAssertionError(entity string, keyFmt string, args ...interface{}) error

func NewUnauthorized

func NewUnauthorized(keyFmt string, args ...interface{}) error

func NewUnknownError

func NewUnknownError(entity string, details string, keyFmt string, args ...interface{}) error

Types

type HttpError added in v0.31.0

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

func (HttpError) Code added in v0.33.0

func (e HttpError) Code() string

func (HttpError) Error added in v0.31.0

func (e HttpError) Error() string

func (HttpError) HTTPStatus added in v0.31.0

func (e HttpError) HTTPStatus() int

func (HttpError) Unwrap added in v0.31.0

func (e HttpError) Unwrap() error

Jump to

Keyboard shortcuts

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