Back to godoc.org
zgo.at/utils/errorutil

package errorutil

v1.4.3
Latest Go to latest
Published: Mar 16, 2020 | License: MIT | Module: zgo.at/utils

Overview

Package errorutil provides functions to work with errors.

Index

Constants

const (
	FilterTraceExclude = 0 // Exclude the paths that match.
	FilterTraceInclude = 1 // Include only the paths that match.
)

Modes for FilterPatterns.

func FilterTrace

func FilterTrace(err error, p *Patterns) error

FilterTrace removes unneeded stack traces from an error.

type Patterns

type Patterns struct {
	// contains filtered or unexported fields
}

Patterns for filtering error traces.

func FilterPattern

func FilterPattern(mode int, paths ...string) *Patterns

FilterPattern compiles filter patterns for FilterTrace()

Frames are filtered according to the mode; with FilterTraceExclude all frames are included except those that match the given patterns. With FilterTraceInclude all frames are excluded except those that match one of the patterns.

Paths starting with re: are treated as a regular expression.

Paths starting with match: are matched with filepath.Match()

Paths ending with .go are matches against the full file path (i.e. /home/martin/go/src/.../file.go).

Anything else is matches against the package path (i.e. github.com/foo/bar).

func (Patterns) Match

func (p Patterns) Match(pc uintptr) bool

Match a file path.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier