Documentation ¶
Overview ¶
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 }
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // AlwaysTrace will, if set globally, enable tracing on all errors. AlwaysTrace bool // AlwaysDebug will, if set globally, enable debug messages on all errors. AlwaysDebug bool )
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct { Code int // contains filtered or unexported fields }
Error is our custom error with description, file, and line.
func (*Error) Contains ¶
Contains is a predicate that returns if any errors in the combined error collection that are of this error.
func (*Error) ContainsFunc ¶
ContainsFunc is like Contains but instead iterates over the errors and executes a predicate function instead.
func (*Error) SetDebug ¶
SetDebug enables the per-error caller information of errored's Error struct.
Click to show internal directories.
Click to hide internal directories.