withstack

package
v0.0.0-...-458fe30 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOneLineSource

func GetOneLineSource(err error) (file string, line int, fn string, ok bool)

GetOneLineSource extracts the file/line/function information of the topmost caller in the innermost recorded stack trace. The filename is simplified to remove the path prefix. This is used e.g. to populate the "source" field in PostgreSQL errors.

func WithStack

func WithStack(err error) error

WithStack annotates err with a stack trace at the point WithStack was called.

Detail is shown: - via `errors.GetSafeDetails()` - when formatting with `%+v`. - in Sentry reports. - when innermost stack capture, with `errors.GetOneLineSource()`.

func WithStackDepth

func WithStackDepth(err error, depth int) error

WithStackDepth annotates err with a stack trace starting from the given call depth. The value zero identifies the caller of WithStackDepth itself. See the documentation of WithStack() for more details.

Types

type ReportableStackTrace

type ReportableStackTrace = sentry.Stacktrace

ReportableStackTrace aliases the type of the same name in the sentry package. This is used by the 'report' error package.

func GetReportableStackTrace

func GetReportableStackTrace(err error) *ReportableStackTrace

GetReportableStackTrace extracts a stack trace embedded in the given error in the format suitable for Sentry reporting.

This supports:

  • errors generated by github.com/pkg/errors (either generated locally or after transfer through the network),
  • errors generated with WithStack() in this package,
  • any other error that implements a StackTrace() method returning a StackTrace from github.com/pkg/errors.

Note: Sentry wants the oldest call frame first, so the entries are reversed in the result.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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