Documentation
¶
Index ¶
- Variables
- func As(err error, target any) bool
- func Errorf(format string, a ...any) error
- func In[T comparable](err error, code T) bool
- func Is(err, target error) bool
- func Join(errs ...error) error
- func New(text string) error
- func Unwrap(err error) error
- func Wrap(err error) error
- type Builder
- type Comparable
- type Error
- func (ex Error[T]) Code() T
- func (ex *Error[T]) Error() string
- func (ex *Error[T]) In(code T) bool
- func (ex *Error[T]) Is(err error) bool
- func (ex *Error[T]) LogValue() slog.Value
- func (ex *Error[T]) MarshalJSON() ([]byte, error)
- func (ex Error[T]) Stacktrace() Stack
- func (ex *Error[T]) String() string
- func (ex *Error[T]) Unwrap() error
- type Option
- type Stack
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Stacktrace = func() Stack { return nil }
View Source
var Unspecified = struct{}{}
Functions ¶
Types ¶
type Builder ¶ added in v1.0.4
type Builder[T comparable] Error[T]
func Code ¶ added in v1.0.4
func Code[T comparable](code T) Builder[T]
func Override ¶ added in v1.0.4
func Override[T comparable](msg string) Builder[T]
type Comparable ¶ added in v1.0.4
type Comparable[T comparable] interface { In(T) bool }
type Error ¶ added in v1.0.4
type Error[T comparable] struct { // contains filtered or unexported fields }
func Be ¶ added in v1.0.4
func Be[T comparable](err error) *Error[T]
Example ¶
ex := Be[struct{}](New("...")) switch ex.Code() { case Unspecified: // do something default: // do something }
Output:
func (*Error[T]) MarshalJSON ¶ added in v1.0.4
func (Error[T]) Stacktrace ¶ added in v1.0.4
type Option ¶ added in v1.0.4
type Option[T comparable] struct { // contains filtered or unexported fields }
func Empty ¶ added in v1.0.4
func Empty[T comparable](code T) Option[T]
func NaN ¶ added in v1.0.4
func NaN[T comparable](code T) Option[T]
Click to show internal directories.
Click to hide internal directories.