package errorutil

import "github.com/teamwork/utils/errorutil"

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.

Functions

func FilterTrace

func FilterTrace(err error, p *Patterns) error

FilterTrace removes unneeded stack traces from an error.

Types

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.

Source Files

errorutil.go

Version
v1.0.0 (latest)
Published
Mar 14, 2022
Platform
windows/amd64
Imports
7 packages
Last checked
now

Tools for package owners.