errors

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2019 License: MPL-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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