errors

package module
v2.0.9 Latest Latest
Warning

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

Go to latest
Published: May 8, 2021 License: MIT Imports: 4 Imported by: 15

Documentation

Overview

Package errors.

This package can be used as drop-in replacement for https://golang.org/pkg/errors package.

This package provide StackTrace function to get the stack trace.

Stack trace can be attached to any error by passing it to Trace function.

New, NewWithCause, and Errorf function will return error that have stack trace.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As

func As(err error, target interface{}) bool

see https://golang.org/pkg/errors/#As

func Catch added in v2.0.2

func Catch(f func() error) (err error)

run f, if f panic or returned, that value will be returned by this function

func Errorf

func Errorf(format string, a ...interface{}) error

see https://golang.org/pkg/fmt/#Errorf

func Format

func Format(err error) string

Format representation of the Error, including stack trace.

Use err.Error() if you want to get just the error string

func FormatWithFilter added in v2.0.8

func FormatWithFilter(err error, filter func(trace.Location) bool) string

like Format, but you can filter what location to include in the formated string

func Go added in v2.0.2

func Go(report func(error), f func() error)

Spawn go routine

run f, if f panic or returned, that value will be passed to report function

the non-nil reported error will return non-nil when passed to ParentStackTrace

func Is

func Is(err, target error) bool

see https://golang.org/pkg/errors/#Is

func NewWithCause

func NewWithCause(text string, cause error) error

like New, but you can specify the cause error

func ParentStackTrace added in v2.0.1

func ParentStackTrace(err error) []trace.Location

Get paren goroutine stack trace of err

return nil if err doesn't have stack trace

func StackTrace

func StackTrace(err error) []trace.Location

Get stack trace of err

return nil if err doesn't have stack trace

func Trace added in v2.0.4

func Trace(err error) error

Trace will return new error that have stack trace

will return same err if err already have stack trace

Types

This section is empty.

Directories

Path Synopsis
Package trace provide utility to get stack trace.
Package trace provide utility to get stack trace.

Jump to

Keyboard shortcuts

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