errors

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2020 License: MPL-2.0, MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(errs *[]error, err error) bool

func WriteErrList

func WriteErrList(w io.Writer, errs ...error)

Types

type Config

type Config struct {
	// RuntimeFrames is true if stack traces should retain frames from the runtime package.
	RuntimeFrames bool

	// TestingFrames is true if stack traces should retain frames from the testing package.
	TestingFrames bool

	// EventLoc is true if Event.Loc should be populated.
	EventLoc bool

	// Stack is true if Error.Stack should be populated.
	Stack bool

	// Cause is true if Error.Cause should be populated and all Error.Msg values should be restored
	// to their original values (without messages of prior causes appended).
	Cause bool
}

func DefaultConfig

func DefaultConfig() Config

type Error

type Error struct {
	// Msg is message from the topmost error.
	Msg string

	// Loc is the error creation site, if available (e.g. from pkg/errors).
	Loc Location

	// Stack includes locations leading to, but excluding, Error.Loc, if available (e.g. from pkg/errors).
	Stack []Location `json:",omitempty"`

	// Cause includes the errors leading to, but excluding, this Error, if available (e.g. from pkg/errors).
	Cause []Error `json:",omitempty"`
}

type Event

type Event struct {
	// Loc is the event creation site.
	Loc Location

	// Errors holds one or more errors collected at the event creation site.
	Errors []Error
}

Event aims to provide error detail for inclusion in a structured log.

It omits a time value, assuming the structured logger will include it.

func NewConfiguredEvent

func NewConfiguredEvent(config Config, errs ...error) (*Event, error)

func NewEvent

func NewEvent(errs ...error) (*Event, error)

type Location

type Location struct {
	// File is an absolute path or relative path from GOROOT/GOPATH.
	File string

	Func string
	Line string
	Pkg  string
}

Jump to

Keyboard shortcuts

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