verr

package module
v0.0.0-...-0006922 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2018 License: MIT Imports: 5 Imported by: 0

README

verr - variadic errors

verr is a Go package created as a response to github.com/pkg/errors. I like the overall idea and how it solves some of the important error handling problems, however, I find it a bit limited and inconvenient for a flexible error handling in a way I want it to be. Thus, this package has been born from it.

Any contributions are very welcome.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LevelMap = map[ErrLevel]string{
	ErrIgnorable: "ignorable",
	ErrInfo:      "info",
	ErrNotice:    "notice",
	ErrWarning:   "warning",
	ErrError:     "error",
	ErrCritical:  "critical",
	ErrFatal:     "fatal",
	ErrPanic:     "panic",
}
View Source
var StackEnabled = true

Functions

func Cause

func Cause(err error) error

func Code

func Code(err error) int

func Params

func Params(err error) map[string]interface{}

Types

type ErrLevel

type ErrLevel int

Error severance level type. Can be used to determine the importance of the error before it handled appropriately.

const (
	ErrError ErrLevel = iota
	ErrIgnorable
	ErrInfo
	ErrNotice
	ErrWarning
	ErrCritical
	ErrFatal
	ErrPanic
)

func Level

func Level(err error) ErrLevel

type Frame

type Frame uintptr

Frame represents a program counter inside a stack frame.

func (Frame) Format

func (f Frame) Format(s fmt.State, verb rune)

Format formats the frame according to the fmt.Formatter interface.

%s    source file
%d    source line
%n    function name
%v    equivalent to %s:%d

Format accepts flags that alter the printing of some verbs, as follows:

%+s   function name and path of source file relative to the compile time
      GOPATH separated by \n\t (<funcname>\n\t<path>)
%+v   equivalent to %+s:%d

type StackTrace

type StackTrace []Frame

StackTrace is stack of Frames from innermost (newest) to outermost (oldest).

func (StackTrace) Format

func (st StackTrace) Format(s fmt.State, verb rune)

Format formats the stack of Frames according to the fmt.Formatter interface.

%s	lists source files for each Frame in the stack
%v	lists the source file and line number for each Frame in the stack

Format accepts flags that alter the printing of some verbs, as follows:

%+v   Prints filename, function, and line number for each Frame in the stack.

type VError

type VError struct {
	Code      int
	Level     ErrLevel
	Msg       string
	Cause     error
	Stack     *stack
	ErrParams map[string]interface{}
}

func Error

func Error(message string) *VError

func Errorf

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

func Wrap

func Wrap(err error, message string) *VError

func (*VError) AddParam

func (fe *VError) AddParam(key string, v interface{}) *VError

func (*VError) Error

func (fe *VError) Error() string

func (*VError) Format

func (fe *VError) Format(s fmt.State, verb rune)

func (*VError) WithCause

func (fe *VError) WithCause(cause error) *VError

func (*VError) WithCode

func (fe *VError) WithCode(code int) *VError

func (*VError) WithLevel

func (fe *VError) WithLevel(level ErrLevel) *VError

Jump to

Keyboard shortcuts

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