Documentation ¶
Index ¶
- Variables
- func As(err error, target interface{}) bool
- func Attr(err error, name string, value interface{}) bool
- func Cause(err error) error
- func Code(err error) (int, bool)
- func FromJSON(data []byte) error
- func Is(first error, second error) bool
- func New(errmsg string, options ...Option) error
- func StackTrace(err error, tracer func(runtime.Frame))
- func TODO(message string) error
- func Unwrap(err error) error
- func Vendor(err error) (string, bool)
- func Wrap(err error, fmtstr string, args ...interface{}) error
- type ErrorCode
- type Option
Constants ¶
This section is empty.
Variables ¶
var Debug = true
Debug print stack information flag
var ErrTODO = New("todo")
ErrTODO errors
Functions ¶
func As ¶
As finds the first error in err's chain that matches target, and if so, sets target to that error value and returns true.
The chain consists of err itself followed by the sequence of errors obtained by repeatedly calling Unwrap.
An error matches target if the error's concrete value is assignable to the value pointed to by target, or if the error has a method As(interface{}) bool such that As(target) returns true. In the latter case, the As method is responsible for setting target.
As will panic if target is not a non-nil pointer to either a type that implements error, or to any interface type. As returns false if err is nil.
func FromJSON ¶ added in v0.0.3
FromJSON unmarshal errorcode from json if any error occur, return nil
func Is ¶
Is Is unwraps its first argument sequentially looking for an error that matches the second. It reports whether it finds a match. It should be used in preference to simple equality checks:
func StackTrace ¶
StackTrace error raise stack trace function
Types ¶
type ErrorCode ¶ added in v0.0.3
type ErrorCode struct { Vendor string `json:"vendor"` Code int `json:"code"` Message string `json:"message"` Attrs map[string]interface{} `json:"attrs"` }
ErrorCode .