errorutil

package
Version: v0.0.0-...-2cb57ea Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dief

func Dief(verbose bool, err error, format string, values ...interface{})

func ErrorAs

func ErrorAs(src error, target error) (error, bool)

Dive into wrapped errors from src until return an error that casts to the target error or such error is not found nolint:golint

func ExpandError

func ExpandError(err error) interface{}

func LogErrorf

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

func LogFatalf

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

func MustSucceed

func MustSucceed(err error, msg ...string)

func TryToUnwrap

func TryToUnwrap(err error) error

Given an error, tries to unwrap it recursively until finds a "trivial" error which cannot be unwrapped anymore. It differs from errors.Unwrap() on returning the error itself in case it cannot be unwrapped, instead of nil

Types

type Chainable

type Chainable interface {
	Chain() ErrorChain
}

type Error

type Error struct {
	Line     int
	Filename string
	Msg      string
	Err      error
}

func Wrap

func Wrap(err error, args ...interface{}) *Error

Wrap an error adding more context such as filename and line where wrapping happened

func (*Error) Chain

func (e *Error) Chain() ErrorChain

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ErrorChain

type ErrorChain []error

func BuildChain

func BuildChain(outer, inner error) ErrorChain

func Chain

func Chain(c Chainable) ErrorChain

Return a chain of errors, from top to bottom of the "stack"

func (ErrorChain) Error

func (chain ErrorChain) Error() string

func (ErrorChain) JSON

func (chain ErrorChain) JSON() []JsonErrorObject

type JsonErrorObject

type JsonErrorObject struct {
	Error string `json:"error,omitempty"`
	File  string `json:"file,omitempty"`
	Line  int    `json:"line,omitempty"`
}

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL