Back to

package errors

v0.0.0 (2b870b0)
Latest Go to latest
Published: 5 days ago | License: MIT | Module:


Package errors adds Wrap(), Wrapf(), and stack traces to stdlib's errors.

Wrap() removes the need for quite a few if err != nil checks and makes migrating from pkg/errors to Go 1.13 errors a bit easier.



var (
	// Package to add trace lines for; if blank all traces are added.
	Package string

	// StackSize is the maximum stack sized added to errors. Set to 0 to
	// disable.
	StackSize int = 32

func As

func As(err error, target interface{}) bool

func Errorf

func Errorf(f string, a ...interface{}) error

func Is

func Is(err, target error) bool

func New

func New(text string) error

func Unwrap

func Unwrap(err error) error

func Wrap

func Wrap(err error, s string) error

Wrap an error with fmt.Errorf(), returning nil if err is nil.

func Wrapf

func Wrapf(err error, format string, a ...interface{}) error

Wrapf an error with fmt.Errorf(), returning nil if err is nil.

type Group

type Group struct {
	// Maximum number of errors; calls to Append() won't do anything if the number of errors is larger than this.
	MaxSize int
	// contains filtered or unexported fields

Group multiple errors.

func NewGroup

func NewGroup(maxSize int) *Group

NewGroup create a new Group instance. It will record a maximum of maxSize errors. Set to 0 for no limit.

func (*Group) Append

func (g *Group) Append(err error)

Append a new error to the list. This is thread-safe.

func (Group) Error

func (g Group) Error() string

func (Group) Len

func (g Group) Len() int

Len returns the number of errors.

type StackErr

type StackErr struct {
	// contains filtered or unexported fields

func (StackErr) Error

func (err StackErr) Error() string

func (StackErr) StackTrace

func (err StackErr) StackTrace() string

func (StackErr) Unwrap

func (err StackErr) Unwrap() error

type StackTracer

type StackTracer interface {
	StackTrace() string
Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier