errors

package
v0.14.4 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As

func As(err error, target any) bool

func GRPCErr

func GRPCErr(err error, msg string) error

func Is

func Is(err, target error) bool

func IsErrorType

func IsErrorType(err error, errType ErrorType) bool

func MultiToError

func MultiToError(e error) error

func Wrap

func Wrap(entity, msg string, err error) error

func WrapIfErr

func WrapIfErr(entity, msg string, err error) error

Types

type DomainError

type DomainError struct {
	ErrorType  ErrorType
	Entity     string
	Message    string
	WrappedErr error
}

func AddErrContext

func AddErrContext(err error, entity, msg string) *DomainError

func AlreadyExists

func AlreadyExists(entity, msg string) *DomainError

func FailedPrecondition added in v0.12.0

func FailedPrecondition(entity, msg string) *DomainError

func InternalError

func InternalError(entity, msg string, err error) *DomainError

func InvalidArgument

func InvalidArgument(entity, msg string) *DomainError

func InvalidStateTransition

func InvalidStateTransition(entity, msg string) *DomainError

func NewError

func NewError(errType ErrorType, entity, msg string) *DomainError

func NotFound

func NotFound(entity, msg string) *DomainError

func (*DomainError) DebugString

func (e *DomainError) DebugString() string

func (*DomainError) Error

func (e *DomainError) Error() string

func (*DomainError) Is

func (*DomainError) Is(tgt error) bool

func (*DomainError) Unwrap

func (e *DomainError) Unwrap() error

type ErrorType

type ErrorType string
const (
	ErrInternalError   ErrorType = "Internal Error"
	ErrNotFound        ErrorType = "Not Found"
	ErrAlreadyExists   ErrorType = "Resource Already Exists"
	ErrInvalidArgument ErrorType = "Invalid Argument"
	ErrFailedPrecond   ErrorType = "Failed Precondition"

	ErrInvalidState ErrorType = "Invalid State"
)

func (ErrorType) String

func (s ErrorType) String() string

type MultiError

type MultiError struct {
	Errors []error
	// contains filtered or unexported fields
}

func NewMultiError

func NewMultiError(msg string) *MultiError

func (*MultiError) Append

func (m *MultiError) Append(err error)

func (*MultiError) Error

func (m *MultiError) Error() string

func (*MultiError) ToErr

func (m *MultiError) ToErr() error

Jump to

Keyboard shortcuts

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