Documentation ¶
Overview ¶
Package e are composed of helper functions to manipulate errors and trace then.
Index ¶
- Constants
- Variables
- func Contains(ie interface{}, sub string) bool
- func Copy(ie interface{}) error
- func Equal(l, r interface{}) bool
- func Find(e, ie interface{}) int
- func FindStr(ie interface{}, sub string) int
- func Forward(ie interface{}) error
- func ForwardN(ie interface{}, n int) error
- func Human(err interface{}) string
- func Merge(e1, e2 interface{}) error
- func New(ie interface{}, a ...interface{}) error
- func NewN(ie interface{}, n int, a ...interface{}) error
- func Phrase(i interface{}) string
- func Push(e1, e2 interface{}) error
- func PushN(e1, e2 interface{}, n int) error
- func String(i interface{}) string
- func Trace(ie interface{}) string
- type Error
- func (e *Error) Arguments() []interface{}
- func (e *Error) Contains(sub string) bool
- func (e *Error) Copy() error
- func (e *Error) Debug() bool
- func (e *Error) DecodeMsgpack(dec *msgpack.Decoder) error
- func (e *Error) EncodeMsgpack(enc *msgpack.Encoder) error
- func (e *Error) Equal(ie interface{}) bool
- func (e *Error) Error() string
- func (e *Error) File() string
- func (e *Error) Find(ie interface{}) int
- func (e *Error) FindStr(sub string) int
- func (e *Error) Forward() *Error
- func (e *Error) GoString() string
- func (e *Error) GobDecode(data []byte) error
- func (e *Error) GobEncode() ([]byte, error)
- func (e *Error) Human() string
- func (e *Error) Line() int
- func (e *Error) Next() *Error
- func (e *Error) Pkg() string
- func (e *Error) Push(ie interface{}) *Error
- func (e *Error) String() string
- func (e *Error) Trace() (s string)
- type GoError
Constants ¶
const ( NextIsNill messageType = iota Next ErrorGo ErrorLocal )
types of error
const ( ErrEmptyString = "empty string" ErrInvalidType = "type is invalid" ErrInvalidLength = "length is invalid" ErrInvalidInterface = "invalid interface" )
Errors
Variables ¶
var Debug = true
Debug add file name and line number to the error
Functions ¶
func Equal ¶
func Equal(l, r interface{}) bool
Equal compare if the errors are the same. l must be *Error and r must be *Error, error or string.
func Find ¶
func Find(e, ie interface{}) int
Find an error in the chain. e must be *Error and ie must be *Error, error or string.
func Forward ¶
func Forward(ie interface{}) error
Forward the error. Only stack the error menssage and the debug data. Free function to use with other types of error besides the *Error. ie must be *Error and r must be *Error, error or string.
func New ¶
func New(ie interface{}, a ...interface{}) error
New initiates an error from a string, error or *Error. a is the verb in the error string that will be replaced when Error and GoString functions is called. The valids verbs are the same verbs in the fmt package.
func Phrase ¶
func Phrase(i interface{}) string
Phrase transform an error message in something readable.
func Push ¶
func Push(e1, e2 interface{}) error
Push e2 error on the top of the stack (e1 error). Free function to use with other types of error beside the *Error. e1 must be *Error or error and e2 must be *Error, error or string.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error expand go error type with debug information and error trace.
func (*Error) Arguments ¶
func (e *Error) Arguments() []interface{}
Arguments return the arguments of one error.
func (*Error) DecodeMsgpack ¶
DecodeMsgpack is a custom msgpack decode function.
func (*Error) EncodeMsgpack ¶
EncodeMsgpack custom msgpack encode function
func (*Error) Equal ¶
Equal compare if the errors are the same. ie must be *Error and r must be *Error, error or string.
func (*Error) FindStr ¶
FindStr find a sub string int the chain of error and return the deep of the error.