errors

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2021 License: MIT Imports: 7 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As

func As(err error, target interface{}) bool

func Is

func Is(err, target error) bool

func New

func New(s string, args ...interface{}) error

func NewWithStackTrace added in v0.12.0

func NewWithStackTrace(skip int, s string, args ...interface{}) error

func Unwrap

func Unwrap(err error) error

func WithStackTrace added in v0.0.2

func WithStackTrace(skip int, err error) error

func Wrap added in v0.3.0

func Wrap(err error, s string, args ...interface{}) error

Types

type ErrorStack added in v0.2.0

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

func (*ErrorStack) AppendError added in v0.2.0

func (s *ErrorStack) AppendError(err error)

Appends an error

func (*ErrorStack) AppendErrorf added in v0.2.0

func (s *ErrorStack) AppendErrorf(str string, args ...interface{})

Appends a described error

func (*ErrorStack) AppendInvalidArgumentError added in v0.12.0

func (s *ErrorStack) AppendInvalidArgumentError(err error, str string, args ...interface{})

Adds wrapped error as InvalidArgument to ErrorStack

func (*ErrorStack) AppendInvalidValueError added in v0.12.0

func (s *ErrorStack) AppendInvalidValueError(err error, str string, args ...interface{})

Adds wrapped error as InvalidValue to ErrorStack

func (*ErrorStack) AppendMissingArgumentError added in v0.12.0

func (s *ErrorStack) AppendMissingArgumentError(err error, str string, args ...interface{})

Adds wrapped error as MissingArgument to ErrorStack

func (*ErrorStack) AppendMissingFieldError added in v0.12.0

func (s *ErrorStack) AppendMissingFieldError(err error, str string, args ...interface{})

Adds wrapped error as MissingField to ErrorStack

func (*ErrorStack) AppendWrapped added in v0.12.0

func (s *ErrorStack) AppendWrapped(err error, str string, args ...interface{})

Appends a described error wrapping another error

func (ErrorStack) Error added in v0.2.0

func (s ErrorStack) Error() string

func (ErrorStack) Errors added in v0.2.0

func (s ErrorStack) Errors() []error

Errors() returns the included errors

func (*ErrorStack) InvalidArgument added in v0.12.0

func (s *ErrorStack) InvalidArgument(str string, args ...interface{})

Adds InvalidArgument to ErrorStack

func (*ErrorStack) InvalidValue added in v0.12.0

func (s *ErrorStack) InvalidValue(str string, args ...interface{})

Adds InvalidValue to ErrorStack

func (*ErrorStack) MissingArgument added in v0.2.0

func (s *ErrorStack) MissingArgument(str string, args ...interface{})

Adds MissingArgument to ErrorStack

func (*ErrorStack) MissingField added in v0.2.0

func (s *ErrorStack) MissingField(str string, args ...interface{})

Adds MissingField to ErrorStack

func (ErrorStack) Ok added in v0.2.0

func (s ErrorStack) Ok() bool

type Frame

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

Heavily based on github.com/pkg/errors.Frame

func Here

func Here() *Frame

func StackFrame

func StackFrame(skip int) *Frame

func (Frame) File added in v0.1.2

func (f Frame) File() string

func (Frame) FileLine added in v0.1.2

func (f Frame) FileLine() string

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>)
%+n   full package name followed by function name
%+v   equivalent to %+s:%d

func (Frame) Line added in v0.1.2

func (f Frame) Line() int

func (Frame) Name

func (f Frame) Name() string

type InvalidArgumentError added in v0.12.0

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

Error representing a Invalid Argument

func AsInvalidArgumentError added in v0.12.0

func AsInvalidArgumentError(err error, str string, args ...interface{}) *InvalidArgumentError

func ErrInvalidArgument added in v0.12.0

func ErrInvalidArgument(str string, args ...interface{}) *InvalidArgumentError

Creates new InvalidArgumentError formatting arguments

func (InvalidArgumentError) Error added in v0.12.0

func (e InvalidArgumentError) Error() string

func (InvalidArgumentError) Unwrap added in v0.12.0

func (e InvalidArgumentError) Unwrap() error

type InvalidValueError added in v0.12.0

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

Error representing a Invalid Value

func AsInvalidValueError added in v0.12.0

func AsInvalidValueError(err error, str string, args ...interface{}) *InvalidValueError

func ErrInvalidValue added in v0.12.0

func ErrInvalidValue(str string, args ...interface{}) *InvalidValueError

Creates new InvalidValueError formatting arguments

func (InvalidValueError) Error added in v0.12.0

func (e InvalidValueError) Error() string

func (InvalidValueError) Unwrap added in v0.12.0

func (e InvalidValueError) Unwrap() error

type MissingArgumentError added in v0.2.0

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

Error representing a Missing Argument

func AsMissingArgumentError added in v0.12.0

func AsMissingArgumentError(err error, str string, args ...interface{}) *MissingArgumentError

func ErrMissingArgument added in v0.2.0

func ErrMissingArgument(str string, args ...interface{}) *MissingArgumentError

Creates new MissingArgumentError formatting arguments

func (MissingArgumentError) Error added in v0.2.0

func (e MissingArgumentError) Error() string

func (MissingArgumentError) Unwrap added in v0.12.0

func (e MissingArgumentError) Unwrap() error

type MissingFieldError added in v0.2.0

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

Error representing a Missing Field

func AsMissingFieldError added in v0.12.0

func AsMissingFieldError(err error, str string, args ...interface{}) *MissingFieldError

func ErrMissingField added in v0.2.0

func ErrMissingField(str string, args ...interface{}) *MissingFieldError

Creates new MissingFieldError formatting arguments

func (MissingFieldError) Error added in v0.2.0

func (e MissingFieldError) Error() string

func (MissingFieldError) Unwrap added in v0.12.0

func (e MissingFieldError) Unwrap() error

type Panic added in v0.0.2

type Panic interface {
	StackTracer

	Error() string
	Recovered() interface{}
}

func Recover added in v0.0.2

func Recover() Panic

type PanicError added in v0.0.2

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

func (*PanicError) Error added in v0.0.2

func (p *PanicError) Error() string

func (*PanicError) Recovered added in v0.0.2

func (p *PanicError) Recovered() interface{}

func (*PanicError) StackTrace added in v0.0.2

func (p *PanicError) StackTrace() Stack

func (*PanicError) Unwrap added in v0.0.2

func (p *PanicError) Unwrap() error

type Stack

type Stack []Frame

func BackTrace

func BackTrace(skip int) Stack

func StackTrace added in v0.1.0

func StackTrace(err error) Stack

func (Stack) Format

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

type StackError added in v0.0.2

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

func (*StackError) Error added in v0.0.2

func (s *StackError) Error() string

func (*StackError) StackTrace added in v0.0.2

func (s *StackError) StackTrace() Stack

func (*StackError) Unwrap added in v0.0.2

func (s *StackError) Unwrap() error

type StackTracer added in v0.0.2

type StackTracer interface {
	StackTrace() Stack
}

func AsStackTracer added in v0.2.0

func AsStackTracer(err error) (StackTracer, bool)

type Validator added in v0.2.0

type Validator interface {
	Ok() bool
	Error() string
	Errors() []error
}

func AsValidator added in v0.2.0

func AsValidator(err error) (Validator, bool)

type Wrapped added in v0.3.0

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

func (*Wrapped) Error added in v0.3.0

func (w *Wrapped) Error() string

func (*Wrapped) Unwrap added in v0.3.0

func (w *Wrapped) Unwrap() error

Jump to

Keyboard shortcuts

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