gomerr

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 9 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 any
}

func BadValue

func BadValue(badValueType BadValueType, name string, value any) *BadValueError

func InvalidValue

func InvalidValue(name string, value any, expected any) *BadValueError

func MalformedValue

func MalformedValue(name string, value any) *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]any

type ConfigurationError

type ConfigurationError struct {
	Gomerr
	Problem string
}

func Configuration

func Configuration(problem string) *ConfigurationError

type ConflictError

type ConflictError struct {
	Gomerr
	With    string
	Id      string
	Problem string
	Source  any
}

func Conflict

func Conflict(with, id, problem string) *ConflictError

func (*ConflictError) WithSource

func (c *ConflictError) WithSource(source any) *ConflictError

type DependencyError

type DependencyError struct {
	Gomerr
	Service string
	Request any
}

func Dependency

func Dependency(service string, request any) *DependencyError

type Gomerr

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

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

	Attribute(key string) (value any)
	AttributeLookup(key string) (value any, ok bool)
	Attributes() map[string]any
	String() string
	ToMap() map[string]any
	// contains filtered or unexported methods
}
var NotAnError Gomerr = &notAnError{}

NotAnError is a sentinel value that looks like a Gomerr but represents "no error." Use errors.Is(err, NotAnError) to detect it explicitly.

func Batch

func Batch(errors ...Gomerr) Gomerr

func Batcher

func Batcher(errors []Gomerr) Gomerr

func Build

func Build(g Gomerr, attributes ...any) 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 any
}

func Marshal

func Marshal(what string, value any) *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 any
}

func Panic

func Panic(recover any) *PanicError

type UnmarshalError

type UnmarshalError struct {
	Gomerr
	What   string
	Data   any
	Target any
}

func Unmarshal

func Unmarshal(what string, data, target any) *UnmarshalError

type UnprocessableError

type UnprocessableError struct {
	Gomerr
	Reason string
	Value  any
}

func Unprocessable

func Unprocessable(reason string, value any) *UnprocessableError

Jump to

Keyboard shortcuts

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