Complex errors for golang
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.travis.yml
LICENSE
README.md
errored.go
errored_test.go

README.md

ReportCard Build GoDoc

Errored: flexible error messages for golang

Package errored implements specialized errors for golang that come with:

  • Debug and Trace modes
    • Debug emits the location the error was created, Trace emits the whole stack.
  • Error combination
    • Make two errors into one; carries the trace information for both errors with it!

Use it just like fmt:

package main

import "github.com/contiv/errored"

func main() {
	err := errored.Errorf("a message")
	err.SetDebug(true)
	err.Error() // => "a message [ <file> <line> <line number> ]"
	err2 := errored.Errorf("another message")
	combined := err.Combine(err2)
	combined.SetTrace(true)
	combined.Error() // => "a message: another message" + two stack traces
  combined.Contains(err2) // true
}

Authors:

  • Madhav Puri
  • Erik Hollensbe

Sponsorship

Project Contiv is sponsored by Cisco Systems, Inc.