Skip to content

contiv/errored

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Releases

No releases published

Packages

No packages published

Languages