errsx

package
v0.0.0-...-41f935c Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Must

func Must[T any](value T, err error) T

Must is an alias for Must1.

func Must0

func Must0(err error)

Must0 accepts any function call that returns an error. If error is not nil then it panics.

func Must1

func Must1[T any](value T, err error) T

Must1 accepts any function call that returns two values, T and error. If error is not nil then it panics, otherwise it returns the value T.

func MustOK

func MustOK[T any](value T, ok bool) T

MustOK accepts any function call that returns two values, T and bool. If bool is false then it panics, otherwise it returns the value T.

Types

type Map

type Map map[string]error

Map represents a collection of errors keyed by name.

func (Map) Err

func (m Map) Err() error

func (Map) Error

func (m Map) Error() string

func (Map) Get

func (m Map) Get(key string) error

func (Map) GetString

func (m Map) GetString(key string) string

func (*Map) Has

func (m *Map) Has(key string) bool

func (Map) MarshalJSON

func (m Map) MarshalJSON() ([]byte, error)

func (*Map) Set

func (m *Map) Set(key string, msg any)

Set associates the given error with the given key. The map is lazily instantiated if it is nil.

func (Map) String

func (m Map) String() string

type Slice

type Slice []error

Slice represents a collection of errors.

func (*Slice) Append

func (s *Slice) Append(value any)

Append pushes the given error onto the end of the slice. Any nil errors are ignored and discarded.

func (Slice) As

func (s Slice) As(target any) bool

func (Slice) Err

func (s Slice) Err() error

func (Slice) Error

func (s Slice) Error() string

func (Slice) String

func (s Slice) String() string

func (Slice) Unwrap

func (s Slice) Unwrap() []error

Jump to

Keyboard shortcuts

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