errors

package
v1.34.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2023 License: GPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	As     = errors.As
	Is     = errors.Is
	Cause  = errors.Cause
	Unwrap = errors.Unwrap
)

Export a number of functions or variables from pkg/errors. We want people to be able to use them, if only via the entrypoints we've vetted in this file.

Functions

func New

func New(msg string, args ...interface{}) error

New acts as pkg/errors.New does, producing a stack traced error, but supports interpolating of message parameters. Use this when you want the stack trace to start at the place you create the error.

func PopStack

func PopStack(err error) error

PopStack removes the top of the stack from an errors stack trace.

func RecoverPanic

func RecoverPanic(r interface{}, errPtr *error)

RecoverPanic turns a panic into an error, adjusting the stacktrace so it originates at the line that caused it.

Example:

func Do() (err error) {
  defer func() {
    errors.RecoverPanic(recover(), &err)
  }()
}

func Sentinel

func Sentinel(msg string, args ...interface{}) error

Sentinel is used to create compile-time errors that are intended to be value only, with no associated stack trace.

func Wrap

func Wrap(cause error, msg string, args ...interface{}) error

Wrap creates a new error from a cause, decorating the original error message with a prefix.

It differs from the pkg/errors Wrap/Wrapf by idempotently creating a stack trace, meaning we won't create another stack trace when there is already a stack trace present that matches our current program position.

Types

type StackTrace

type StackTrace = errors.StackTrace

StackTrace should be aliases rather than newtype'd, so it can work with any of the functions we export from pkg/errors.

type StackTracer

type StackTracer interface {
	StackTrace() errors.StackTrace
}

Jump to

Keyboard shortcuts

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