errors

package
v3.8.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2022 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cause

func Cause(err error) error

Cause returns the underlying cause of the error, if possible. An error value has a cause if it implements the following interface:

type causer interface {
       Cause() error
}

If the error does not implement Cause, the original error will be returned. If the error is nil, nil will be returned without further investigation.

DEPRECATED: Use logan/v3 instead

func FromPanic

func FromPanic(rec interface{}) error

FromPanic extracts the err from the result of a recover() call.

DEPRECATED: Use logan/v3 instead

func New

func New(msg string) error

New returns an error with the supplied message. New also records the stack trace at the point it was called.

DEPRECATED: Use logan/v3 instead

func Wrap

func Wrap(base error, msg string) error

Wrap returns an error annotating err with a stack trace at the point Wrap is called, and the supplied message. If err is nil, Wrap returns nil.

DEPRECATED: Use logan/v3 instead

Types

type F

type F map[string]interface{}

F type is for fields, connected to `withFields` error.

DEPRECATED: Use logan/v3 instead

func GetFields

func GetFields(err error) F

GetFields returns the underlying fields of the error and its nested cause-errors, if possible. An error value has fields if it (or any of its nested cause) implements the following interface:

type fieldsProvider interface {
       GetFields() F
}

If the error and all of its nested causes do not implement GetFields, empty fields map will be returned.

DEPRECATED: Use logan/v3 instead

func WithField

func WithField(key string, value interface{}) F

WithField creates new `F` fields map and add provided key-value pair into it using Add method.

DEPRECATED: Use logan/v3 instead

func (F) Add

func (f F) Add(key string, value interface{}) F

Add tries to extract fields from `value`, if `value` implements fields.Provider interface:

type Provider interface {
	GetLoganFields() map[string]interface{}
}

And adds these fields using AddFields. If `value` does not implement Provider - a single key-value pair is added.

DEPRECATED: Use logan/v3 instead

func (F) AddFields

func (f F) AddFields(newF F) F

AddFields returns `F` map, which contains key-values from both maps. If both maps has some key - the value from the `newF` will be used.

DEPRECATED: Use logan/v3 instead

func (F) ToError

func (f F) ToError(message string) error

ToError returns new error with `message` and `f` fields.

DEPRECATED: Use logan/v3 instead

func (F) Wrap

func (f F) Wrap(base error, message string) error

Wrap wraps `base` error with `message` and adds `f` fields to the error. Returns nil if `base` is nil, which copies the `errors.Wrap` behaviour.

DEPRECATED: Use logan/v3 instead

Jump to

Keyboard shortcuts

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