errors

package
v0.0.0-...-4221fa5 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WithContext

type WithContext interface {
	error

	Context() string
	RawError() string
}

WithContext is an error associated with a logging context string (e.g. `job="foo", instance="bar"`). It is formatted as:

fmt.Sprintf("[%s] %s", Context(), RawError())

func Errorf

func Errorf(context, format string, a ...interface{}) WithContext

Errorf formats according to a format specifier and returns a new WithContext.

func New

func New(context, err string) WithContext

New creates a new WithContext.

func Wrap

func Wrap(context string, err error) WithContext

Wrap returns a WithContext wrapping err. If err is nil, it returns nil. If err is a WithContext, it is returned unchanged.

func Wrapf

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

Wrapf returns a WithContext that prepends a formatted message to err.Error(). If err is nil, it returns nil. If err is a WithContext, the returned WithContext will have the message prepended but the same context as err (presumed to be more specific).

Jump to

Keyboard shortcuts

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