stackerr

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

README

Stackerr

GoDoc Latest Version Go Report Card

Stackerr is a lightweight, un-opinionated Go package for errors with stack traces.


Installation

go get github.com/go-andiamo/stackerr

Documentation

Overview

Package stackerr - Go package for errors with stack trace

Index

Constants

This section is empty.

Variables

View Source
var DefaultPackageName string

DefaultPackageName is the default (short) package name to be used to check which packages are to be captured for the errors stack info

View Source
var MaxStackDepth uint = 16

MaxStackDepth is the maximum stack depth to capture

Functions

func SetDefaultPackageFilter

func SetDefaultPackageFilter(pkg string)

SetDefaultPackageFilter sets the DefaultPackageFilter with a filter for the specified package

Types

type FrameFormatter

type FrameFormatter interface {
	StartLine() string
	FrameLine(frame runtime.Frame) string
}
var DefaultFrameFormatter FrameFormatter = &frameFormatter{}

DefaultFrameFormatter is the formatter used to format call stack frames when formatting StackError

If this is set to nil, no stack info is output when formatting StackError

type PackageFilter

type PackageFilter interface {
	Include(packageName string) bool
}

PackageFilter is the interface used by DefaultPackageFilter

var DefaultPackageFilter PackageFilter

DefaultPackageFilter is the default package filter used to determine which packages are to be captured for the errors stack info

type StackError

type StackError interface {
	error
	// WithCause returns a StackError with the cause set
	WithCause(cause error) StackError
	Unwrap() error
	Cause() error
	// StackInfo returns the call stack info for the error
	StackInfo() StackInfo
}

StackError is an error interface with stack info

func New

func New(msg string) StackError

New creates a new StackError with stack info

func Newf

func Newf(format string, args ...any) StackError

Newf creates a new StackError with stack info and a formatted message

func Wrap

func Wrap(err error, msg string) StackError

Wrap wraps an existing error with a StackError

Note: the stack info is based on the point at which Wrap is called (rather than the callers of the wrapped error)

type StackInfo

type StackInfo []runtime.Frame

Jump to

Keyboard shortcuts

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