Documentation
¶
Index ¶
- Constants
- func Encode(e error) string
- func Errorf(format string, args ...interface{}) error
- func Has(err error, k Kind) (error, bool)
- func Is(err error, k Kind) bool
- func New(args ...interface{}) error
- func Serialize(err error, args ...interface{}) []byte
- func Str(text string) error
- type Error
- type Kind
- type Location
Constants ¶
const ( Sep = "\n\t" RecordSep = "\036" // byte(30) || "\x1e" ... is the ascii Record Separator (RS) character UnitSep = "\037" // byte(31) || "\x1e" ... is the ascii Unit Separator (US) character )
Sep and UnitSep are used to separate/delim fields
Variables ¶
This section is empty.
Functions ¶
func Encode ¶ added in v0.0.5
Encode takes the error and DSV encodes is for storage. It's a bit esoteric to use byte(30) and byte(31) as delimeters, but that's why those characters exist. Without type info, this isn't all that useful.
func Errorf ¶
Errorf is equivalent to fmt.Errorf, but allows clients to import only this package for all error handling.
func Has ¶ added in v0.0.7
Has checks to see if the error is of a certain kind. It returns the (matching error, true) or the (nil, false)
func New ¶
func New(args ...interface{}) error
New creates a new Error of our own liking. The `string` args are assumed to be the error message. The `error`/`Error` arg is assumed to be a Prev. The `Location` arg is assumed to be the Location. The `Kind` arg is the Kind of the error.
func Serialize ¶ added in v0.0.2
Serialize writes the entire stack using a binary encoding. The args passed should be the latest (topmost) error and a []byte to populate. The []byte arg will see almost no usage as it's primarily used for the recursive serializing. Although it's certainly not out of the realm of possibility that there is a []byte to be filled.
Types ¶
type Error ¶
type Error struct { Err string `json:"error,omitempty"` // this error Kind Kind `json:"kind,omitempty"` // the Kind of this error Location Location `json:"location,omitempty"` // the location of this error Prev error `json:"previous,omitempty"` // the previous error }
Error is an error with an embedded "previous" error and a kind
func (*Error) Error ¶
Error fulfills the error interface. The error stack will be of the format: `message[[[ = kind] @ location]\n\t]`
func (*Error) Serialize ¶ added in v0.0.2
Serialize writes the entire stack using the format 'int64(len)[]bytes(value)'
func (*Error) Unserialize ¶ added in v0.0.5
Unserialize reads the byte slice into the receiver, which must be non-nil. The returned error is always nil.
type Kind ¶ added in v0.0.5
type Kind uint8
Kind is a custom int type to communicate the error's Kind.