errors

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: Apache-2.0 Imports: 8 Imported by: 18 modules, 388 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package errors provides an api similar to github.com/nuclio/nuclio/pkg/errors However we don't carry stack trace around for performance (see https://github.com/pkg/errors/issues/124)

Index

Constants

This section is empty.

Variables

View Source
var (
	// ShowLineInfo sets if we collect location information (file, line)
	// (getting location information makes creating error slower ~550ns vs 2ns)
	ShowLineInfo bool
)

Functions

func Cause

func Cause(err error) error

Cause is the cause of the error

func Errorf

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

Errorf returns a new Error

func GetErrorStack

func GetErrorStack(err error, depth int) []error

GetErrorStack return stack of messges (oldest on top) if n == -1 returns the whole stack

func GetErrorStackString

func GetErrorStackString(err error, depth int) string

GetErrorStackString returns the error stack as a string

func Is

func Is(base, target error) bool

func New

func New(message string) error

New returns a new error

func PrintErrorStack

func PrintErrorStack(out io.Writer, err error, depth int)

PrintErrorStack prints the error stack into out up to depth levels If n == 1 then prints the whole stack

func RootCause

func RootCause(err error) error

RootCause is the cause of the error

func Wrap

func Wrap(err error, message string) error

Wrap returns a new error with err as cause, if err is nil will return nil

func Wrapf

func Wrapf(err error, format string, args ...interface{}) error

Wrapf returns a new error with err as cause, if err is nil will return nil

Types

type Error

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

Error implements error interface with call stack

func (*Error) Cause

func (err *Error) Cause() error

Cause returns the cause of the error

func (*Error) Error

func (err *Error) Error() string

Error is the string representation of the error

func (*Error) Format

func (err *Error) Format(s fmt.State, verb rune)

Format formats an error

func (*Error) LineInfo

func (err *Error) LineInfo() (string, int)

LineInfo info returns the location (file, line) where the error was created

func (*Error) Unwrap

func (err *Error) Unwrap() error

Jump to

Keyboard shortcuts

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