Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Errorf ¶
Errorf saves stack trace and pass arguments to fmt.Errorf.
Example ¶
err := stack.Errorf("annotated: %w", errOrigin) fmt.Println(errors.Is(err, errOrigin))
Output: true
func Origin ¶
Origin returns unwrapped origin of the error.
Example ¶
err := frameA() fmt.Println(stack.Origin(err))
Output: origin
func Trace ¶
Trace returns stack trace for error.
Example ¶
err := frameA() for _, frame := range stack.Trace(err) { fmt.Printf("%s:%d %s()\n", frame.File, frame.Line, frame.Function) } // Example output: // github.com/romanyx/stack/helper_test.go:16 github.com/romanyx/stack_test.frameB() // github.com/romanyx/stack/helper_test.go:12 github.com/romanyx/stack_test.frameA() // github.com/romanyx/stack/example_test.go:10 github.com/romanyx/stack_test.ExampleTrance() // /usr/local/go/src/testing/run_example.go:62 testing.runExample() // /usr/local/go/src/testing/example.go:44 testing.runExamples() // /usr/local/go/src/testing/testing.go:1118 testing.(*M).Run() // _testmain.go:52 main.main() // /usr/local/go/src/runtime/proc.go:203 runtime.main() // /usr/local/go/src/runtime/asm_amd64.s:1357 runtime.goexit()
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.