errgo

package module
v0.0.0-...-5b21d03 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2014 License: LGPL-3.0 Imports: 5 Imported by: 26

README

errgo

A package for the Go language to provide extra information for errors.

Documentation

Overview

errgo is a package that provides an easy way to annotate errors without losing the orginal error context.

Index

Constants

This section is empty.

Variables

View Source
var Default = OutputParams{FileDepth: 2}

Default is a simple pre-defined params for the DetailedErrorStack method that has no prefix, and shows files to a depth of one.

Functions

func Annotate

func Annotate(err error, message string) error

Annotate is used to add extra context to an existing error. The location of the Annotate call is recorded with the annotations. The file, line and function are also recorded.

func Annotatef

func Annotatef(err error, format string, args ...interface{}) error

Annotatef operates like Annotate, but uses the a format and args that match the fmt package.

func Check

func Check(err error, checker func(error) bool) bool

Check looks at the underling error to see if it matches the checker function.

func DetailedErrorStack

func DetailedErrorStack(err error, params OutputParams) string

DetailedErrorStack gives a slice containing the detailed error stack, annotation and original error, along with the location if it was recorded.

func GetErrorStack

func GetErrorStack(err error) []error

GetErrorStack returns a slice of errors stored in the annotated errors. If the error isn't an annotated error, a slice with a single value is returned.

func New

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

New creates a new error and records the location that the error is created.

func Trace

func Trace(err error) error

Trace records the location of the Trace call, and adds it to the annotation stack.

func Translate

func Translate(err, newError error, message string) error

Translate records the newError along with the message in the annotation stack.

func Translatef

func Translatef(err, newError error, format string, args ...interface{}) error

Translatef operates like Translate, but uses the a format and args that match the fmt package.

Types

type OutputParams

type OutputParams struct {
	Prefix    string
	FileDepth int
}

OutputParams are used to control the look of the DetailedErrorStack.

Jump to

Keyboard shortcuts

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