errors

package module
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 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, use Wrap to make sure the error 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 Errorf

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

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

func ErrorfWithDeep

func ErrorfWithDeep(deep int, format string, a ...interface{}) error

like Errorf, but you can specify the stack trace deep

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 FormatWithDeep

func FormatWithDeep(err error, deep int) string

FormatWithDeep representation of the Error, including stack trace with specified deep.

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

func Ignore

func Ignore(err error)

Ignore the err

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 NewWithCauseAndDeep

func NewWithCauseAndDeep(deep int, text string, cause error) error

like NewWithCause, but you can specify the stack trace deep

func NewWithDeep

func NewWithDeep(deep int, text string) error

like New, but you can specify the stack trace deep

func StackTrace

func StackTrace(err error) []trace.Location

Get stack trace of where the error is generated, return nil if none

func Wrap

func Wrap(err error) error

Wrap the err if the err doens't have stack trace

func WrapWithDeep

func WrapWithDeep(deep int, err error) error

like Wrap, but you can specify the stack trace deep

Types

type StackTracer

type StackTracer interface {
	StackTrace() []trace.Location
}

StackTracer indicate that the error have stack trace

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