Documentation ¶
Index ¶
- func Cause(err error) error
- func Errorf(format string, args ...interface{}) error
- func IsKind(err error, k Kind) bool
- func New(msg string, args ...interface{}) error
- func Str(text string) error
- func WithKind(err error, kind Kind, msg string) error
- func WithKindf(err error, kind Kind, format string, args ...interface{}) error
- func WithMessage(err error, message string) error
- func WithMessagef(err error, format string, args ...interface{}) error
- func WithOp(err error, op Op) error
- func WithOpf(err error, op Op, format string, args ...interface{}) error
- func WithStack(err error) error
- func Wrap(err error, message string) error
- func Wrapf(err error, format string, args ...interface{}) error
- type Error
- type Kind
- type Monad
- type Op
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cause ¶
Cause returns the underlying cause of the error, if possible. An error value has a cause if it implements the following interface:
type causer interface { Cause() error }
If the error does not implement Cause, the original error will be returned. If the error is nil, nil will be returned without further investigation.
func Errorf ¶
Errorf is equivalent to fmt.Errorf, but allows clients to import only this package for all error handling.
func IsKind ¶ added in v0.2.3
IsKind returns a boolean signifying if the error matches the Kind provided in the input
func New ¶
New builds an error value from its arguments. There must be at least one argument or New panics. The type of each argument determines its meaning. If more than one argument of a given type is presented, only the last one is recorded.
The types are:
errors.op The operation being performed, usually the method being invoked (Get, Put, etc.). errors.kind The class of error, such as permission failure. error The underlying error that triggered this one.
If the error is printed, only those items that have been set to non-zero values will appear in the result.
If Kind is not specified or Internal, we set it to the Kind of the underlying error.
func Str ¶
Str returns an error that formats as the given text. It is intended to be used as the error-typed argument to the E function.
func WithKind ¶
WithKind returns an error annotating err with the service specific kind of err at the point WithKind is called. If err is nil, WithKind returns nil.
func WithKindf ¶
WithKindf returns an error annotating err with the service specific kind of err at the point WithKindf is call, and the format specifier. If err is nil, WithKindf returns nil.
func WithMessage ¶
WithMessage annotates err with a new message. If err is nil, WithMessage returns nil.
func WithMessagef ¶
WithMessagef formats an err with a new message. If err is nil, WithMessage returns nil.
func WithOp ¶
WithOp returns an error annotating err with a hint of the operation name at the point WithOp is called. If err is nil, WithOp returns nil.
func WithOpf ¶
WithOpf returns an error annotating err with a hint of the operation name at the point WithOpf is call, and the format specifier. If err is nil, WithOpf returns nil.
func WithStack ¶
WithStack annotates err with a stack trace at the point WithStack was called. If err is nil, WithStack returns nil.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is the type that implements the error interface. It contains a number of fields, each of different type. An Error value may leave some values unset.
func Serializable ¶ added in v0.2.3
Serializable returns a serializable error struct that cna omit exposing internal errors as an option in release mode
func Unwrap ¶
Unwrap returns the first occurrence of the underlying *Error type using causer or create a new *Error type containing the original error's message
func (*Error) MarshalJSON ¶
MarshalJSON converts the err object to the JSON representation
func (*Error) UnmarshalJSON ¶
UnmarshalJSON deserializes JSON back to Error struct
type Kind ¶
type Kind int
Kind defines the kind of error this is, mostly for use by systems such as FUSE that must act differently depending on the error.
const ( Internal Kind = iota // Internal error or inconsistency. Invalid // Invalid operation for this type of item. Permission // Permission denied. IO // External I/O error such as network failure. AlreadyExist // Item already exists. NotExist // Item does not exist. NotImplemented // Method not implemented )
Kinds of errors.
The values of the error kinds are common between both clients and servers. Do not reorder this list or remove any items since that will change their values. New items must be added only to the end.
func KindOf ¶
KindOf returns the underlying kind type of the error, if possible. An error value has a kind if it implements the following interface:
type kinder interface { Kind() Kind }
If the error does not implement Kind, the original error will be returned. If the error is nil, Internal will be returned without further investigation.