errors

package module
v0.0.0-...-8ec427b Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2017 License: MIT Imports: 6 Imported by: 1

README

errors (unstable & incomplete)

leeola/errors is a simple package meant to summarize an errors history as it propagates through your program. As you wrap errors, it will keep track of each file location and the added error context. The package has various methods to extract this information in meaningful ways. errors.Println(err) and s := errors.Sprintln(err) for example.

If the originating error (the one not from leeola/errors) is needed, errors.Cause(err) can be used to extract the original error.

Example

~/g/s/g/l/errors> go run _example/example.go
Baz() returned an error.

err.Error():
Bar() failed: Foo() failed: os.Open failed: open fakefile.txt: no such file or directory

errors.Println(err):
errors/_example/example.go:13: os.Open failed: open fakefile.txt: no such file or directory
errors/_example/example.go:21: Foo() failed
errors/_example/example.go:29: Bar() failed

errors.Cause(err).Error():
open fakefile.txt: no such file or directory

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cause

func Cause(err error) error

func Equals

func Equals(a error, b error) bool

Equals checks if a and b are the same, have the same cause, or variations within.

func Errorf

func Errorf(f string, s ...interface{}) error

func Join

func Join(errs []error) error

func JoinSep

func JoinSep(errs []error, sep string) error

func New

func New(s string) error

func Println

func Println(err error)

func Split

func Split(err error) []error

func Sprintln

func Sprintln(err error) string

func Stack

func Stack(err error) error

Stack wraps the given error with a stack line without a new message.

func Wrap

func Wrap(err error, s string) error

func Wrapf

func Wrapf(err error, f string, s ...interface{}) error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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