Documentation ¶
Overview ¶
Package xerrors provides a stack of multiple errors that can be pushed to, popped from, and concatenated.
Index ¶
- type ErrorStack
- type Errors
- func (e *Errors) As(target interface{}) bool
- func (e *Errors) Clear()
- func (e *Errors) Concat() error
- func (e *Errors) Copy() *ErrorsImmutable
- func (e *Errors) Error() string
- func (e *Errors) Errors() []error
- func (e *Errors) Is(sought error) bool
- func (e *Errors) Len() int
- func (e *Errors) Next() error
- func (e *Errors) Pop() error
- func (e *Errors) PopAll() []error
- func (e *Errors) PopAllImmutable() *ErrorsImmutable
- func (e *Errors) Push(err error)
- func (e *Errors) Seek(offset int64, whence int) (int64, error)
- type ErrorsImmutable
- func (e *ErrorsImmutable) As(i interface{}) bool
- func (e *ErrorsImmutable) Error() string
- func (e *ErrorsImmutable) Errors() []error
- func (e *ErrorsImmutable) Is(err error) bool
- func (e *ErrorsImmutable) Len() int
- func (e *ErrorsImmutable) Next() error
- func (e *ErrorsImmutable) Seek(offset int64, whence int) (int64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorStack ¶
type Errors ¶
type Errors struct {
// contains filtered or unexported fields
}
Errors is a stack of multiple errors that can be pushed to, popped from, or concatenated. It is safe for concurrent use, and can return an immutable copy of itself as an [errstack.ErrorsImmutable].
func (*Errors) Concat ¶
Concat concatenates all errors in the stack into a single error. It does not clear the original stack.
func (*Errors) Copy ¶
func (e *Errors) Copy() *ErrorsImmutable
Copy returns an immutable copy of the error stack. It does not clear the original stack. Copy is safe to call concurrently.
func (*Errors) Error ¶
Error implements the error interface. Internally it uses Errors.Concat.
func (*Errors) Errors ¶
Errors returns a slice containing a copy of all errors in the stack. It does not clear the original stack.
func (*Errors) Next ¶
Next returns the next error in the stack, incrementing the internal index. If we've reached the end of the stack, it returns nil.
Use [errstack.Errors.Seek] to rewind the internal index if needed.
func (*Errors) Pop ¶
Pop pops one error from the stack, removing it from the stack and returning it.
func (*Errors) PopAllImmutable ¶
func (e *Errors) PopAllImmutable() *ErrorsImmutable
PopAllImmutable returns an immutable copy of the error stack, and clears the original stack, leaving it empty.
type ErrorsImmutable ¶
type ErrorsImmutable struct {
// contains filtered or unexported fields
}
ErrorsImmutable is a stack of multiple errors popped from [errstack.Errors]. Internally it contains a private [errstack.Errors] with the immutable flag set to true.
It's public methods are a partial subset of [errstack.Errors] methods operating as pass-throughs. Consequently, more information on the contained methods can be found in the [errstack.Errors] documentation.
func (*ErrorsImmutable) As ¶
func (e *ErrorsImmutable) As(i interface{}) bool
func (*ErrorsImmutable) Error ¶
func (e *ErrorsImmutable) Error() string
func (*ErrorsImmutable) Errors ¶
func (e *ErrorsImmutable) Errors() []error
func (*ErrorsImmutable) Is ¶
func (e *ErrorsImmutable) Is(err error) bool
func (*ErrorsImmutable) Len ¶
func (e *ErrorsImmutable) Len() int
func (*ErrorsImmutable) Next ¶
func (e *ErrorsImmutable) Next() error