package stack

import "github.com/containerd/errdefs/stack"

Index

Variables

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

Source Files

stack.go

Version
v0.2.0
Published
Sep 2, 2024
Platform
darwin/amd64
Imports
12 packages
Last checked
5 hours ago

Tools for package owners.