withstack

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2019 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 Frame

type Frame = pkgErr.Frame

Frame is the type of a single call frame entry. This mirrors the type of the same name in github.com/pkg/errors.

type ReportableStackTrace

type ReportableStackTrace = raven.Stacktrace

ReportableStackTrace aliases the type of the same name in the raven (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 raven/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.

type StackTrace

type StackTrace = pkgErr.StackTrace

StackTrace is the type of the data for a call stack. This mirrors the type of the same name in github.com/pkg/errors.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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