errors

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultUserFriendlyError = "something went wrong"

Functions

func As

func As(err error, target any) bool

As is a wrapper over std function to avoid multiple errors package imports

func In

func In(err error, target ...any) bool

func Is

func Is(err error, target any) bool

func IsUserFriendly

func IsUserFriendly(err error) bool

func Join

func Join(errs ...error) error

func Raw

func Raw(err error) error

Types

type Error

type Error interface {
	Annotate(message string, args ...interface{}) Error
	Wrap(error) Error
	Unwrap() error
	Labels() LabelList
	WithLabels(...Label) Error
	Details() map[string]string
	WithDetails(map[string]string) Error

	error
}

func From

func From(err error) Error

func New

func New(kind Kind, message string, args ...interface{}) Error

func NewAlreadyExistsError

func NewAlreadyExistsError(message string, args ...interface{}) Error

NewAlreadyExistsError returns an AlreadyExists error.

func NewAuthenticationError

func NewAuthenticationError(message string, args ...interface{}) Error

NewAuthenticationError returns an Authentication error.

func NewAuthorizationError

func NewAuthorizationError(message string, args ...interface{}) Error

NewAuthorizationError returns an Authorization error.

func NewBadRequestError

func NewBadRequestError(message string, args ...interface{}) Error

NewBadRequestError returns an BadRequest error.

func NewInconsistentError

func NewInconsistentError(message string, args ...interface{}) Error

NewInconsistentError returns an Inconsistent error.

func NewInfrastructureError

func NewInfrastructureError(message string, args ...interface{}) Error

NewInfrastructureError returns an Infrastructure error.

func NewLimitExceededError

func NewLimitExceededError(message string, args ...interface{}) Error

NewLimitExceededError returns an LimitExceeded error.

func NewNotFoundError

func NewNotFoundError(message string, args ...interface{}) Error

NewNotFoundError returns an NotFound error.

func NewPersistenceError

func NewPersistenceError(message string, args ...interface{}) Error

NewPersistenceError returns an Persistence error.

func NewThirdPartiesError

func NewThirdPartiesError(message string, args ...interface{}) Error

NewThirdPartiesError returns an ThirdParties error.

func NewTimeoutError

func NewTimeoutError(message string, args ...interface{}) Error

NewTimeoutError returns an Timeout error.

func NewValidationError

func NewValidationError(message string, args ...interface{}) Error

NewValidationError returns an Validation error.

type Factory

type Factory interface {
	WithLabels(...Label) Factory
	New(args ...interface{}) Error
}

func NewAlreadyExistsFactory

func NewAlreadyExistsFactory(template string) Factory

NewAlreadyExistsFactory returns an error factory that creates AlreadyExists user-friendly errors.

func NewAuthenticationFactory

func NewAuthenticationFactory(template string) Factory

NewAuthenticationFactory returns an error factory that creates Authentication user-friendly errors.

func NewAuthorizationFactory

func NewAuthorizationFactory(template string) Factory

NewAuthorizationFactory returns an error factory that creates Authorization user-friendly errors.

func NewBadRequestFactory

func NewBadRequestFactory(template string) Factory

NewBadRequestFactory returns an error factory that creates BadRequest user-friendly errors.

func NewFactory

func NewFactory(kind Kind, template string) Factory

func NewInconsistentFactory

func NewInconsistentFactory(template string) Factory

NewInconsistentFactory returns an error factory that creates Inconsistent user-friendly errors.

func NewInfrastructureFactory

func NewInfrastructureFactory(template string) Factory

NewInfrastructureFactory returns an error factory that creates Infrastructure user-friendly errors.

func NewLimitExceededFactory

func NewLimitExceededFactory(template string) Factory

NewLimitExceededFactory returns an error factory that creates LimitExceeded user-friendly errors.

func NewNotFoundFactory

func NewNotFoundFactory(template string) Factory

NewNotFoundFactory returns an error factory that creates NotFound user-friendly errors.

func NewPersistenceFactory

func NewPersistenceFactory(template string) Factory

NewPersistenceFactory returns an error factory that creates Persistence user-friendly errors.

func NewThirdPartiesFactory

func NewThirdPartiesFactory(template string) Factory

NewThirdPartiesFactory returns an error factory that creates ThirdParties user-friendly errors.

func NewTimeoutFactory

func NewTimeoutFactory(template string) Factory

NewTimeoutFactory returns an error factory that creates Timeout user-friendly errors.

func NewValidationFactory

func NewValidationFactory(template string) Factory

NewValidationFactory returns an error factory that creates Validation user-friendly errors.

type Kind

type Kind uint
const (
	ErrKindGeneral Kind = iota
	ErrKindAuthentication
	ErrKindAuthorization
	ErrKindBadRequest
	ErrKindValidation
	ErrKindNotFound
	ErrKindAlreadyExists
	ErrKindLimitExceeded
	ErrKindInconsistent
	ErrKindPersistence
	ErrKindInfrastructure
	ErrKindThirdParties
	ErrKindTimeout
)

func KindOf

func KindOf(err error) Kind

func ParseKind

func ParseKind(code string) Kind

type Label

type Label string
const (
	LabelUserFriendly Label = "user-friendly"
)

type LabelList

type LabelList []Label

func Labels

func Labels(err error) LabelList

func (LabelList) Add

func (self LabelList) Add(labels ...Label) LabelList

func (LabelList) Has

func (self LabelList) Has(label Label) bool

type Stacker

type Stacker interface {
	StackTrace() jsontext.Value
	Location() string

	error
}

Directories

Path Synopsis