errors

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

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

Go to latest
Published: Jun 14, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsError

func ContainsError(lookFor, err error) (error, map[string]interface{}, bool)

ContainsError takes an error to look for and the error that needs to analyse. It compares the errors by comparing the string returned by Error().

func ContainsErrorPrefix

func ContainsErrorPrefix(prefixMsg string, err error) (error, map[string]interface{}, bool)

ContainsErrorPrefix takes a prefix msg to look and an error chain and returns the error if it is found.

Types

type GenericError

type GenericError interface {
	error
	IsGenericError() bool
}

GenericError is an interface of the error to use as an example of how to write a Contains function.

func ContainsGenericError

func ContainsGenericError(err error) (GenericError, map[string]interface{}, bool)

ContainsGenericError takes an error and returns a concrete error if it is present in the error chain.

type WrappedError

type WrappedError interface {
	error
	IsWrappedError() bool
	GetPrevious() error
	GetActual() error
	GetFields() map[string]interface{}
	GetAllFields() map[string]interface{}
	GetStacktrace() string
}

WrappedError specifies the interface for a wrapped error.

type WrappedErrorImpl

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

WrappedErrorImpl is a wrapper for an error chain that allow to specify errors fields.

func NewWithError

func NewWithError(actual error) *WrappedErrorImpl

NewWithError returns a new WrappedErrorImpl with the provided error.

func NewWithErrorAndFields

func NewWithErrorAndFields(actual error, fields map[string]interface{}) *WrappedErrorImpl

NewWithErrorAndFields returns a new WrappedErrorImpl with the provided error and fields.

func NewWithMsg

func NewWithMsg(message string) *WrappedErrorImpl

NewWithMsg returns a new WrappedErrorImpl with the provided message.

func NewWithMsgAndFields

func NewWithMsgAndFields(message string, fields map[string]interface{}) *WrappedErrorImpl

NewWithMsgAndFields returns a new WrappedErrorImpl with the provided message and fields.

func WithError

func WithError(previous error, actual error) *WrappedErrorImpl

WithError takes the previous error and the actual error and, returns a new WrappedErrorImpl.

func WithErrorAndFields

func WithErrorAndFields(previous error, actual error, fields map[string]interface{}) *WrappedErrorImpl

WithErrorAndFields takes the previous error, the actual error and the fields associated with it and returns a new WrappedErrorImpl.

func (*WrappedErrorImpl) Error

func (e *WrappedErrorImpl) Error() string

Error returns stack of all the wrapped error messages and it associated fields.

func (WrappedErrorImpl) GetActual

func (e WrappedErrorImpl) GetActual() error

GetActual returns the actual wrapped error in the chain.

func (WrappedErrorImpl) GetAllFields

func (e WrappedErrorImpl) GetAllFields() map[string]interface{}

GetAllFields returns a map of the fields for all the errors that had been wrap in the chain.

func (WrappedErrorImpl) GetFields

func (e WrappedErrorImpl) GetFields() map[string]interface{}

GetFields returns the fields associated with the actual error.

func (WrappedErrorImpl) GetPrevious

func (e WrappedErrorImpl) GetPrevious() error

GetPrevious returns the previous error in the chain.

func (WrappedErrorImpl) GetStacktrace

func (e WrappedErrorImpl) GetStacktrace() string

GetStacktrace returns the stack trace of the first error in the chain.

func (WrappedErrorImpl) IsWrappedError

func (e WrappedErrorImpl) IsWrappedError() bool

IsWrappedError returns always true for this error type.

Jump to

Keyboard shortcuts

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