errs

package
v0.0.0-...-3ca17b7 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorTypeForbidden      = ErrorType{"forbidden"}
	ErrorTypeAuthorization  = ErrorType{"authorization"}
	ErrorTypeIncorrectInput = ErrorType{"incorrect-input"}
	ErrorTypeNotFound       = ErrorType{"not-found"}
	ErrorTypeConflict       = ErrorType{"conflict"}
	ErrorTypeAlreadyExists  = ErrorType{"already-exists"}
)

is Error type exposed to client

View Source
var ErrInvalidInput = errors.New("invalid input")
View Source
var (
	ErrorTypeUnknown = ErrorType{"unknown"}
)

Error types not exposed to client

Functions

func IsErrorType

func IsErrorType(err error, errType ErrorType) bool

Types

type Error

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

func E

func E(op Op, err error, errType ErrorType, message string) *Error

func NewAlreadyExistsError

func NewAlreadyExistsError(op Op, err error, message string) *Error

func NewAuthorizationError

func NewAuthorizationError(op Op, err error, message string) *Error

func NewConflictError

func NewConflictError(op Op, err error, message string) *Error

func NewForbiddenError

func NewForbiddenError(op Op, err error, message string) *Error

func NewIncorrectInputError

func NewIncorrectInputError(op Op, err error, message string) *Error

func NewNotFound

func NewNotFound(op Op, err error, message string) *Error

func NewUnknownError

func NewUnknownError(op Op, err error, message string) *Error

func WithOp

func WithOp(op Op, err error, msg string) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) HasOperation

func (e *Error) HasOperation(op Op) bool

func (*Error) Is

func (e *Error) Is(target error) bool

func (*Error) Log

func (e *Error) Log(logger *slog.Logger)

func (*Error) Message

func (e *Error) Message() map[string]string

func (*Error) Operations

func (e *Error) Operations() []OpMessage

func (*Error) Type

func (e *Error) Type() ErrorType

func (*Error) Unwrap

func (e *Error) Unwrap() error

func (*Error) WithContext

func (e *Error) WithContext(key string, value any) *Error

func (*Error) WithMessages

func (e *Error) WithMessages(messages []Message) *Error

type ErrorType

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

func (ErrorType) Is

func (e ErrorType) Is(target ErrorType) bool

func (ErrorType) String

func (e ErrorType) String() string

type Message

type Message struct {
	Key   string
	Value string
}

type Op

type Op string

Op describes an operation, usually as the package and method, such as db.get_user.

type OpMessage

type OpMessage struct {
	Op      Op
	Message string
}

func (OpMessage) String

func (o OpMessage) String() string

Jump to

Keyboard shortcuts

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