Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // PackageRegexp is regexp search that help us find those lines that // includes function calls in our package and its sub packages. The // following lines help you figure out what kind of lines we are talking // about: // github.com/lainio/err2/try.To1[...](...) // github.com/lainio/err2/assert.Asserter.True(...) PackageRegexp = regexp.MustCompile(`lainio/err2[a-zA-Z0-9_/.\[\]]*\(`) )
Functions ¶
func FprintStack ¶
FprintStack prints the stack trace returned by runtime.Stack to the writer. The StackInfo tells what it prints from the stack.
func FuncName ¶ added in v0.8.12
FuncName is similar to runtime.Caller, but instead to return program counter or function name with full path, funcName returns just function name, separated filename, and line number. If frame cannot be found ok is false.
See more information from runtime.Caller. The StackInfo tells how many stack frames we should go back (Level), and other fields tell how to find the actual line where calculation should be started.
func PrintStack ¶
func PrintStack(stackLevel int)
PrintStack prints to standard error the stack trace returned by runtime.Stack by starting from stackLevel.
func PrintStackForTest ¶ added in v0.9.1
PrintStackForTest prints to io.Writer the stack trace returned by runtime.Stack and processed to proper format to be shown in test output by starting from stackLevel.
Types ¶
type StackInfo ¶
type StackInfo struct { PackageName string FuncName string Level int *regexp.Regexp // these are used to filter out specific lines from output ExlRegexp []*regexp.Regexp PrintFirstOnly bool }
StackInfo has two parts. The first part is for anchor line, i.e., line in the call stack that we want to include, and where output starts. The second part is ExlRegexps that are used to filter out lines from final output.