Documentation ¶
Overview ¶
Package errors provides a way to generate contextual errors.
Index ¶
Constants ¶
View Source
const ( // Context indicates a context.Context error. Context = Category("context-error") // Decode indicates that decoding failed. Decode = Category("decode") // Encode indicates that encoding failed. Encode = Category("encode") // Existent indicates that an element already exists. Existent = Category("existent") // Invalid indicates a validation constraint. Invalid = Category("invalid") // Permanent indicates that the error is permanent – use along Transient. Permanent = Category("permanent") // NonExistent indicates that an element doesn't exist. NonExistent = Category("non-existent") // Transient indicates that the error is transient – use along Permanent. Transient = Category("transient") )
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(args ...interface{}) error
New creates a contextual error by accepting different arguments listed below. The arguments need to be passed in that order to end up with a consistent error.
- `context.Context` If the context has erroed, a Context category is added to the list of categories.
- `string` The given message is added to the error stack.
- `contextualError` The existing error stack, categories and tags are preserved and/or extended.
- `error` The error message is added to the error stack.
- `Category` The given type is stacked. It can be later be accessed with `Is`.
- `kv.Pair` To provide more contextual data points.
Types ¶
Click to show internal directories.
Click to hide internal directories.