Help us shape the future of Go! Take the 2026 Go Developer Survey

errorsx

package
v1.129.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package errorsx creates errors that record the call stack where they start.

Go errors carry no stack, so sentry-go gives an event the stack of the CaptureException call. Every failure reported from one place then shares one stack, and Sentry groups unrelated causes into one issue. An error from this package exposes its origin stack through StackTrace() []uintptr, which sentry-go reads, so Sentry groups the event by where the failure started.

Use New or Errorf where an error starts, and WithStack where an error from an external library enters the backend. Keep package-level sentinel errors as errors.New: a stack recorded at program start has no value.

github.com/pkg/errors is not used: it is archived, its Errorf does not support %w, and its Wrap records a new stack on each wrap.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorf

func Errorf(format string, args ...any) error

Errorf formats like fmt.Errorf, %w included. It records the stack of the caller, unless a wrapped error already has a stack: the origin stack is the one that tells failures apart.

func HasStack

func HasStack(err error) bool

HasStack reports whether err, or an error that it wraps, records a stack.

func New

func New(msg string) error

New returns an error with the message msg and the stack of the caller.

func WithStack

func WithStack(err error) error

WithStack adds the stack of the caller to err. It returns err unchanged when err is nil or already has a stack.

Types

This section is empty.

Directories

Path Synopsis
Package errorsxtest helps tests check the origin stack that Sentry records for an error.
Package errorsxtest helps tests check the origin stack that Sentry records for an error.

Jump to

Keyboard shortcuts

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