Documentation ¶
Overview ¶
Package errortrace provides a method to track function stacktrace and populate it in case of error.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IgnoreFunc ¶
func IgnoreFunc(fn interface{}) string
IgnoreFunc can be used to ignore the specified function in a package for the trace.
func IgnorePackage ¶
func IgnorePackage(fn interface{}) string
IgnorePackage can be used to ignore all functions in a package for the trace.
func IgnoreStruct ¶
func IgnoreStruct(fn interface{}) string
IgnoreStruct can be used to ignore all struct functions in the trace.
Types ¶
type Call ¶
type Call struct { PackageName string FunctionPath string FunctionName string File string Line int PC uintptr Entry uintptr FullName string }
Call represents a call on the stack.
type ErrorTrace ¶
type ErrorTrace struct {
// contains filtered or unexported fields
}
ErrorTrace represents an ErrorTrace, it includes the parent trace (if called with Prepare).
func (*ErrorTrace) Error ¶ added in v0.5.0
func (et *ErrorTrace) Error() string
Error returns the string representation for the error. It includes the Stacktrace, Description and Context.
func (*ErrorTrace) ErrorText ¶ added in v0.5.0
func (et *ErrorTrace) ErrorText() string
ErrorText returns only the error text for the error.
func (*ErrorTrace) Is ¶ added in v0.5.6
func (et *ErrorTrace) Is(err error) bool
Is implements the xerrors interface so we can use the xerrors.Is() function.
func (*ErrorTrace) SetContext ¶ added in v0.5.0
func (et *ErrorTrace) SetContext(ctx string)
SetContext sets the context information that should be printed for this error.
func (*ErrorTrace) SetDescription ¶ added in v0.5.0
func (et *ErrorTrace) SetDescription(description string)
SetDescription sets the description that should be printed for this error.
func (*ErrorTrace) SetError ¶ added in v0.5.0
func (et *ErrorTrace) SetError(err error)
SetError sets the error.
func (*ErrorTrace) Unwrap ¶ added in v0.5.6
func (et *ErrorTrace) Unwrap() error
Unwrap implements the xerrors.Wrapper interface.
type Template ¶ added in v0.5.0
type Template struct {
// contains filtered or unexported fields
}
Template is used as a factory to create a new ErrorTrace when you need it, use New() to create an Template.
func (*Template) Prepare ¶ added in v0.5.0
func (t *Template) Prepare() *ErrorTrace
Prepare collects the current trace, if later a Panic will be called the collected trace will be included in the error trace.