errors

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//KTransient is an error kind that may happen outside the application invariants (network failure, service down)
	// transient errors must only be associated with retryable idempotent domain
	KTransient = 0x0000
	//KPersistent is an error kind that is considered inside the application invariants (bad input, wrong initialisation order)
	// persistent errors are generally unrecoverable due to bad domain invariants, or programming errors
	KPersistent = 0x7000

	//DResource is an error domain for resources (database model, configuration, etc...)
	DResource = 0x0100
	//DService is an error domain for services (clients, database drivers, etc...)
	DService = 0x0200
	//DTemporal is an error domain for everything `time` related (timeout, tickers, etc...)
	DTemporal = 0x0300
	//DSize is an error domain for sizeable items (array, buffer, etc...)
	DSize = 0x0400
	//DLogic is an error domain for logic (loops, control-flow, etc...)
	DLogic = 0x0500
	//DIO is an error domain for IO (file, http-transport, etc...)
	DIO = 0x0600
	//DUser is an error domain related to user interactions (form submission, user inputs, etc...)
	DUser = 0x0700
	//DEncoding is an error domain related to serialization (JSON, text, etc...)
	DEncoding = 0x0800
	//DDependency is an error domain related to dependencies, mostly used by the di system
	DDependency = 0x0900
	//DSynchro is an error domain related to synchronisation semantics (context, mutex, etc...)
	DSynchro = 0x0a00
	//DType is an error domain related to the type system (any, reflection, etc...)
	DType = 0x0b00
	//DValue is an error domain related to values
	DValue = 0x0c00
	//DTransport is an error domain related to transports (tcp, etc...)
	DTransport = 0x0d00

	//ANotFound is an error axiom for missing or not found items
	ANotFound = 0x0010
	//AMalformed is an error axiom for malformed or corrupted items
	AMalformed = 0x0020
	//AInvariant is an error axiom for invariants (eg: nil check)
	AInvariant = 0x0030
	//ATooBig is an error axiom mostly for sizeable items (mostly used in conjunction with `DSize`)
	ATooBig = 0x0040
	//ATooSmall is an error axiom mostly for sizeable items (mostly used in conjunction with `DSize`)
	ATooSmall = 0x0050
	//AUnexpected is an error axiom used to mark an interaction as unwanted
	AUnexpected = 0x0060
	//AUnreachable is an error axiom used to define unreachable areas of code or logic
	AUnreachable = 0x0070
	//AUnimplemented is an error axiom for missing domain
	AUnimplemented = 0x0080
	//ANil is an error axiom for nil values
	ANil = 0x0090
	//ATimeout is an error relating to time outs
	ATimeout = 0x00a0
)

Variables

View Source
var (
	//EInvalidContext signals that a context is no longer valid, but should have been at the time of invocation
	EInvalidContext = PersistentCode(DSynchro, AInvariant)
	//ENotImplemented signals that this part of logic was not implemented
	ENotImplemented = PersistentCode(DLogic, AUnimplemented)
	//EInvalidCast todo
	EInvalidCast = PersistentCode(DType, AInvariant)
	//EUnreachable todo
	EUnreachable = PersistentCode(DLogic, AUnreachable)
	// ENil todo
	ENil = PersistentCode(DType, ANil)
)

Functions

func All

func All(fns ...func() error) error

All executes a list of `func() error` and stops at the first non-nil error encountered

func AllCtx

func AllCtx(ctx context.Context, fns ...func(ctx context.Context) error) error

AllCtx executes a list of `func(context.Context) error` and stops if the `context.Context` is no longer valid, or at the first non-nil error encountered

func Code

func Code(kind, ns, axiom uint16) stacktrace.ErrorCode

func HasAnyFlag added in v0.1.1

func HasAnyFlag(err error, flags ...uint16) bool

func HasCode

func HasCode(err error, code stacktrace.ErrorCode) bool

func HasFlag

func HasFlag(err error, flag uint16) bool

func InstallPanicObserver

func InstallPanicObserver()

func InvalidCast

func InvalidCast(expected, got any) error

func IsNotFoundCode

func IsNotFoundCode(bit uint16) bool

func IsPersistentCode

func IsPersistentCode(bit uint16) bool

func IsTransient

func IsTransient(err error) bool

func IsTransientCode

func IsTransientCode(bit uint16) bool

func Must

func Must(err error)

func Mustf

func Mustf(err error, format string, args ...any)

func NewGroup

func NewGroup() []error

func NotImplemented

func NotImplemented(reason string) error

func Persistent

func Persistent(bit uint16) uint16

func PersistentCode

func PersistentCode(ns, axiom uint16) stacktrace.ErrorCode

func RegisterAxiom

func RegisterAxiom(flag uint16, name string)

func RegisterDomain

func RegisterDomain(flag uint16, name string)

func ResourceNotFound

func ResourceNotFound(bit uint16) uint16

func Transient

func Transient(bit uint16) uint16

func TransientCode

func TransientCode(ns, axiom uint16) stacktrace.ErrorCode

func ValidateContext

func ValidateContext(ctx context.Context) error

Types

type DiagnosticManifest

type DiagnosticManifest struct {
	Transient bool
	Domain    string
	Axiom     string
	Error     error
	// contains filtered or unexported fields
}

func Diagnostic

func Diagnostic(err error) DiagnosticManifest

func (DiagnosticManifest) String

func (d DiagnosticManifest) String() string

type Group

type Group []error

func (*Group) Append

func (g *Group) Append(errs ...error)

func (Group) Coalesce

func (g Group) Coalesce() error

func (Group) First

func (g Group) First() error

type Registry

type Registry struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Registry) Axiom

func (r *Registry) Axiom(code uint16) string

func (*Registry) Domain

func (r *Registry) Domain(code uint16) string

func (*Registry) RegisterAxiom

func (r *Registry) RegisterAxiom(flag uint16, name string) *Registry

func (*Registry) RegisterDomain

func (r *Registry) RegisterDomain(flag uint16, name string) *Registry

Jump to

Keyboard shortcuts

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