Help us shape the future of Go! Take the 2026 Go Developer Survey

errorstack

package module
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSkip = errors.New("skip this error")

ErrSkip is used as a return value from WalkFuncs to indicate that the error in the call is to be skipped. It is not returned as an error by any function.

Functions

This section is empty.

Types

type Stack

type Stack struct {
	// contains filtered or unexported fields
}

Stack is a stack of error.

func Convert added in v0.2.1

func Convert(err error) *Stack

Convert returns a converted error stack.

func New

func New(errs ...error) *Stack

New returns an error stack.

func (*Stack) Attach added in v0.4.1

func (s *Stack) Attach(errs ...error) *Stack

Attach pushes error stack into the stack.

func (*Stack) Copy

func (s *Stack) Copy() *Stack

Copy creates a copy of error stack.

func (*Stack) Empty

func (s *Stack) Empty() bool

Empty reports whether the error stack is empty.

func (*Stack) Error

func (s *Stack) Error() string

Error is the implementation of error.

func (*Stack) Find

func (s *Stack) Find(err error, max int) []int

Find gets the level of given error appears within the first max times. If max < 0, there is no limit on the number of times. If not found, will return empty array.

An error is considered to match a target if it is equal to that target or if it implements a method Is(error) bool such that Is(target) returns true.

func (*Stack) First

func (s *Stack) First(err error) int

First gets the first level of given error appears. If not found, will return 0.

func (*Stack) FirstStack added in v0.2.1

func (s *Stack) FirstStack(err *Stack) int

FirstStack gets the first level of given error stack appears. If not found, will return 0.

func (*Stack) Format

func (s *Stack) Format(state fmt.State, verb rune)

Format is the implementation of formater.

func (*Stack) Get

func (s *Stack) Get(level int) error

Get gets the error of given level.

func (*Stack) Has

func (s *Stack) Has(err error) bool

Has reports whether the error stack contains given error.

func (*Stack) HasStack added in v0.2.1

func (s *Stack) HasStack(err *Stack) bool

HasStack reports whether the error stack contains given error stack.

func (*Stack) Is added in v0.2.1

func (s *Stack) Is(err error) bool

Is reports whether the error stack is given error.

func (*Stack) IsStack added in v0.2.1

func (s *Stack) IsStack(err *Stack) bool

IsStack reports whether the error stack is given error stack.

func (*Stack) Last

func (s *Stack) Last() error

Last gets the last error.

func (*Stack) Level

func (s *Stack) Level() int

Level gets the total level of the error stack has. If the stack is empty, will return 0.

func (*Stack) MarshalJSON added in v0.4.0

func (s *Stack) MarshalJSON() ([]byte, error)

MarshalJSON is the implementation of JSON marshaler.

func (*Stack) Pop

func (s *Stack) Pop(errs []error) *Stack

Pop pops errors off the stack, errs start from last.

func (*Stack) Push

func (s *Stack) Push(errs ...error) *Stack

Push pushes errors into the stack.

func (*Stack) Root

func (s *Stack) Root() error

Root gets the root error.

func (*Stack) Walk

func (s *Stack) Walk(walkFn WalkFunc) error

Walk walks the error stack from root.

type WalkFunc

type WalkFunc func(level int, err error) error

WalkFunc is the type of the function called for each error visited by Walk.

Jump to

Keyboard shortcuts

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