errtrace

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wrap

func Wrap(err error, opts ...Option) error

Wrap wraps an error with the function call trace. Returns nil if the given error is nil.

Example (Default)
fmt.Println(foo())
Output:

runtime.main: main.main: testing.(*M).Run: testing.runExamples: testing.runExample: github.com/NikitaShlyakhtin/errtrace.ExampleWrap_default: github.com/NikitaShlyakhtin/errtrace.foo: github.com/NikitaShlyakhtin/errtrace.bar: internal error
Example (WithDelimiter)
fmt.Println(foo(WithDelimiter("\n")))
Output:

runtime.main
main.main
testing.(*M).Run
testing.runExamples
testing.runExample
github.com/NikitaShlyakhtin/errtrace.ExampleWrap_withDelimiter
github.com/NikitaShlyakhtin/errtrace.foo
github.com/NikitaShlyakhtin/errtrace.bar: internal error
Example (WithHideFullPaths)
fmt.Println(foo(WithHideFullPaths()))
Output:

runtime.main: main.main: testing.(*M).Run: testing.runExamples: testing.runExample: errtrace.ExampleWrap_withHideFullPaths: errtrace.foo: errtrace.bar: internal error
Example (WithHidePackageNames)
fmt.Println(foo(WithHidePackageNames()))
Output:

main: main: Run: runExamples: runExample: ExampleWrap_withHidePackageNames: foo: bar: internal error

Types

type Option

type Option func(*config)

Option is a functional option for Wrap function.

func WithDelimiter

func WithDelimiter(delimiter string) Option

WithDelimiter override the default delimiter in the function call trace.

func WithHideFullPaths

func WithHideFullPaths() Option

WithHideFullPaths hide full paths in the function call trace.

func WithHidePackageNames

func WithHidePackageNames() Option

WithHidePackageNames hide package names in the function call trace.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL