stackerr

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DEBUG     = false
	CheckArgs = false
)

Functions

func Cleanmodulepath

func Cleanmodulepath(p string) string

func Errorf

func Errorf(format string, args ...interface{}) error

Errorf with stack trace from caller. Use %w to wrap errors!

example:

return stackerr.Errorf("%w", err)

Then elsewhere,

> log.Printf("Error: %+v", err)

Types

type FuncCallerInfo

type FuncCallerInfo struct {
	Name string `json:"name,omitempty"`
	File string `json:"file,omitempty"`
	Line int    `json:"line,omitempty"`
}

func GetFuncCallerInfo

func GetFuncCallerInfo(skips ...int) FuncCallerInfo

func (FuncCallerInfo) String

func (fci FuncCallerInfo) String() string

type StackError

type StackError struct {
	St FuncCallerInfo `json:"caller"`
	// contains filtered or unexported fields
}

func Wrap

func Wrap(err error, skips ...int) *StackError

Wrap with stack trace from caller's caller (nil error returns nil)

func (*StackError) Format

func (s *StackError) Format(f fmt.State, c rune)

func (*StackError) Stack

func (s *StackError) Stack() FuncCallerInfo

func (*StackError) Underlying

func (s *StackError) Underlying() error

func (*StackError) Unwrap

func (s *StackError) Unwrap() error

Jump to

Keyboard shortcuts

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