xerrors

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MPL-2.0 Imports: 2 Imported by: 7

Documentation

Overview

Package xerrors contains the additions to std errors package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTagged

func NewTagged[T Tag](err error) error

NewTagged creates a new typed error.

func NewTaggedf

func NewTaggedf[T Tag](format string, a ...any) error

NewTaggedf creates a new typed error.

func TagIs

func TagIs[T Tag](err error) bool

TagIs is wrapper around errors.As which checks the error tag.

func TypeIs

func TypeIs[T error](err error) bool

TypeIs is wrapper around errors.As which check the error type.

Types

type Tag

type Tag interface {
	~struct{}
}

Tag is a type which can be used to tag Tagged errors.

type Tagged

type Tagged[T Tag] struct {
	// contains filtered or unexported fields
}

Tagged is an error with a tag attached. Tag can only be an empty struct.

func (*Tagged[T]) Error

func (e *Tagged[T]) Error() string

Error implements error interface.

func (*Tagged[T]) Unwrap

func (e *Tagged[T]) Unwrap() error

Unwrap implements errors.Unwrap.

Jump to

Keyboard shortcuts

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