gomerr

package
v0.0.0-...-8f66fda Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorAs

func ErrorAs[E error](err error) (e E)

Types

type BadValueError

type BadValueError struct {
	Gomerr
	Type  BadValueType
	Name  string
	Value interface{}
}

func BadValue

func BadValue(badValueType BadValueType, name string, value interface{}) *BadValueError

func InvalidValue

func InvalidValue(name string, value interface{}, expected interface{}) *BadValueError

func MalformedValue

func MalformedValue(name string, value interface{}) *BadValueError

func ValueExpired

func ValueExpired(name string, expiredAt time.Time) *BadValueError

func (*BadValueError) WithReason

func (bve *BadValueError) WithReason(reason string) *BadValueError

type BadValueType

type BadValueType string
const (
	ExpiredValueType    BadValueType = "Expired"
	GenericBadValueType BadValueType = "BadValue"
	InvalidValueType    BadValueType = "Invalid"
	MalformedValueType  BadValueType = "Malformed"
)

type BatchError

type BatchError struct {
	Gomerr
	// contains filtered or unexported fields
}

func (*BatchError) Errors

func (b *BatchError) Errors() []Gomerr

func (*BatchError) ToMap

func (b *BatchError) ToMap() map[string]interface{}

type ConfigurationError

type ConfigurationError struct {
	Gomerr
	Problem string
}

func Configuration

func Configuration(problem string) *ConfigurationError

type ConflictError

type ConflictError struct {
	Gomerr
	With    interface{}
	Problem string
	Source  interface{}
}

func Conflict

func Conflict(with interface{}, problem string) *ConflictError

func (*ConflictError) WithSource

func (c *ConflictError) WithSource(source interface{}) *ConflictError

type DependencyError

type DependencyError struct {
	Gomerr
	Service string
	Request interface{} `gomerr:"include_type"`
}

func Dependency

func Dependency(service string, request interface{}) *DependencyError

type Gomerr

type Gomerr interface {
	error
	Unwrap() error
	Is(err error) bool

	Wrap(err error) Gomerr
	AddAttribute(key string, value interface{}) Gomerr
	ReplaceAttribute(key string, value interface{}) Gomerr
	DeleteAttribute(key string) Gomerr
	AddAttributes(keysAndValues ...interface{}) Gomerr
	WithAttributes(attributes map[string]interface{}) Gomerr

	Attribute(key string) (value interface{})
	AttributeLookup(key string) (value interface{}, ok bool)
	Attributes() map[string]interface{}
	String() string
	ToMap() map[string]interface{}
	// contains filtered or unexported methods
}

func Batch

func Batch(errors ...Gomerr) Gomerr

func Batcher

func Batcher(errors []Gomerr) Gomerr

func Build

func Build(g Gomerr, attributes ...interface{}) Gomerr

type InternalError

type InternalError struct {
	Gomerr
	Issue string
}

func Internal

func Internal(issue string) *InternalError

type MarshalError

type MarshalError struct {
	Gomerr
	What  string
	Value interface{} `gomerr:"include_type"`
}

func Marshal

func Marshal(what string, value interface{}) *MarshalError

type NotFoundError

type NotFoundError struct {
	Gomerr
	Type string
	Id   string
}

func NotFound

func NotFound(type_ string, id string) *NotFoundError

type PanicError

type PanicError struct {
	Gomerr
	Recover interface{}
}

func Panic

func Panic(recover interface{}) *PanicError

type UnmarshalError

type UnmarshalError struct {
	Gomerr
	What   string
	Data   interface{} `gomerr:"include_type"`
	Target interface{} `gomerr:"include_type"`
}

func Unmarshal

func Unmarshal(what string, data, target interface{}) *UnmarshalError

type UnprocessableError

type UnprocessableError struct {
	Gomerr
	Reason string
	Value  interface{} `gomerr:"include_type"`
}

func Unprocessable

func Unprocessable(reason string, value interface{}) *UnprocessableError

Jump to

Keyboard shortcuts

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