# README
errors
An errors package built on top of existing battle tested packages with structured JSON serialization support.
Requirements
Go v1.10+ since strings.Builder
API is used for generating the output for Error()
method.
Features
- A very primitive support for monads
- Maintains backwards compatibility with Dave Cheney's errors package.
- Additional functions for wrapping errors inspired by Upspin's error package.
- Additional methods for error inspection.
- JSON serialization support.
Prior Art
# Functions
Cause returns the underlying cause of the error, if possible.
Do returns a monad.
Errorf is equivalent to fmt.Errorf, but allows clients to import only this package for all error handling.
IsKind returns a boolean signifying if the error matches the Kind provided in the input.
KindOf returns the underlying kind type of the error, if possible.
New builds an error value from its arguments.
Serializable returns a serializable error struct that cna omit exposing internal errors as an option in release mode.
Str returns an error that formats as the given text.
Unwrap returns the first occurrence of the underlying *Error type using causer or create a new *Error type containing the original error's message.
WithKind returns an error annotating err with the service specific kind of err at the point WithKind is called.
WithKindf returns an error annotating err with the service specific kind of err at the point WithKindf is call, and the format specifier.
WithMessage annotates err with a new message.
WithMessagef formats an err with a new message.
WithOp returns an error annotating err with a hint of the operation name at the point WithOp is called.
WithOpf returns an error annotating err with a hint of the operation name at the point WithOpf is call, and the format specifier.
WithStack annotates err with a stack trace at the point WithStack was called.
Wrap returns an error annotating err with a stack trace at the point Wrap is called, and the supplied message.
Wrapf returns an error annotating err with a stack trace at the point Wrapf is call, and the format specifier.
# Constants
Item already exists.
Internal error or inconsistency.
Invalid operation for this type of item.
External I/O error such as network failure.
Item does not exist.
Method not implemented.
Permission denied.