stacktrace

package
v2.9.3 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package stacktrace contains code borrowed from the github.com/pkg/errors

Package stacktrace contains code borrowed from the github.com/pkg/errors

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendToError added in v2.2.0

func AppendToError(err error, skip ...int) error

AppendToError populates err with a stack trace at the point WithStack was called. If err is nil, WithStack returns nil.

func FormattedStack added in v2.2.0

func FormattedStack(skip int, prefix string) []byte

FormattedStack returns a nicely formatted stack frame, skipping skip frames.

Types

type Frame

type Frame uintptr

Frame represents a program counter inside a stack frame. For historical reasons if Frame is interpreted as an uintptr its value represents the program counter + 1.

func (Frame) Format added in v2.2.0

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

Format formats the frame according to the fmt.Formatter interface.

%s    source file
%d    source line
%n    function name
%v    equivalent to %s:%d

Format accepts flags that alter the printing of some verbs, as follows:

%+s   function name and path of source file relative to the compile time
      GOPATH separated by \n\t (<funcname>\n\t<path>)
%+v   equivalent to %+s:%d

func (Frame) MarshalText added in v2.2.0

func (f Frame) MarshalText() ([]byte, error)

MarshalText formats a stacktrace Frame as a text string. The output is the same as that of fmt.Sprintf("%+v", f), but without newlines or tabs.

type StackTrace added in v2.2.0

type StackTrace []Frame

StackTrace is stack of Frames from innermost (newest) to outermost (oldest).

func (StackTrace) Format added in v2.2.0

func (st StackTrace) Format(s fmt.State, verb rune)

Format formats the stack of Frames according to the fmt.Formatter interface.

%s	lists source files for each Frame in the stack
%v	lists the source file and line number for each Frame in the stack

Format accepts flags that alter the printing of some verbs, as follows:

%+v   Prints filename, function, and line number for each Frame in the stack.

type StackTraced added in v2.2.0

type StackTraced interface {
	StackTrace() StackTrace
}

Jump to

Keyboard shortcuts

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