stack

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version is version of running process
	Version string = "dev"

	// Revision is the specific revision of the running process
	Revision string = "dirty"
)

Functions

func ErrStack

func ErrStack() error

ErrStack returns a new error for the callers stack, this can be wrapped or joined into an existing error. NOTE: When joined with errors.Join, the stack will show up in the error string output. Use with `stack.Join` to force addition of the error stack.

func Join

func Join(errs ...error) error

Join adds a stack if there is no stack included to the errors and returns a joined error with the stack hidden from the error output. The stack error shows up when Unwrapped or formatted with `%+v`.

func WithHelper

func WithHelper(ctx context.Context) context.Context

WithHelper marks the context as from a helper function This will add an additional skip to the error stack trace

func WithStack

func WithStack(ctx context.Context, errs ...error) error

WithStack will check if the error already has a stack otherwise return a new error with the error joined with a stack error Any helpers will be skipped.

Types

type Frame

type Frame struct {
	Name string `json:"Name,omitempty"`
	File string `json:"File,omitempty"`
	Line int32  `json:"Line,omitempty"`
}

Frame is a single frame of the trace representing a line of code

func (Frame) Format

func (f Frame) Format(s fmt.State, verb rune)

type Trace

type Trace struct {
	Version  string   `json:"version,omitempty"`
	Revision string   `json:"revision,omitempty"`
	Cmdline  []string `json:"cmdline,omitempty"`
	Frames   []Frame  `json:"frames,omitempty"`
	Pid      int32    `json:"pid,omitempty"`
}

Trace is a stack trace along with process information about the source

Jump to

Keyboard shortcuts

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