Documentation ¶
Overview ¶
Package probe implements a simple mechanism to trace and return errors in large programs.
Package probe implements a simple mechanism to trace and return errors in large programs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init()
Init initializes probe. It is typically called once from the main() function or at least from any source file placed at the top level source directory.
func SetAppInfo ¶
func SetAppInfo(key, value string)
SetAppInfo sets app speific key:value to report additionally during call trace dump. Eg. SetAppInfo("ReleaseTag", "RELEASE_42_0")
SetAppInfo("Version", "42.0") SetAppInfo("Commit", "00611fb")
Types ¶
type Error ¶
type Error struct { Cause error `json:"cause,omitempty"` CallTrace []TracePoint `json:"trace,omitempty"` SysInfo map[string]string `json:"sysinfo,omitempty"` // contains filtered or unexported fields }
Error implements tracing error functionality.
func NewError ¶
NewError function instantiates an error probe for tracing. Default “error“ (golang's error interface) is injected in only once. Rest of the time, you trace the return path with “probe.Trace“ and finally handling them at top level
Following dummy code talks about how one can pass up the errors and put them in CallTrace.
func sendError() *probe.Error { return probe.NewError(errors.New("Help Needed")) } func recvError() *probe.Error { return sendError().Trace() } if err := recvError(); err != nil { log.Fatalln(err.Trace()) }
func UnwrapError ¶
UnwrapError tries to convert generic 'error' into typed *probe.Error and returns true, false otherwise.