Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatYAML ¶
FormatYAML returns a YAML-formatted string representation of err.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is the base type for module-specific errors.
Every Error contains a single base error, called the "cause".
One or more errors may be wrapped by an Error to express a chain or composition of errors, especially when multiple error conditions apply to a single operation.
When initialized using a Make* constructor (or Wrap), Error records the context in which it was created including the callsite, stacktrace, and datetime.
Many of the module's exported functions return an Error that wraps standard errors from the Go standard library.
Error supports the errors.Is interface so that wrapped external errors can be compared directly.
Error Abstractions ¶
The following constructors return common errors that should be used as containers for more specific errors, or when the specific cause of an error is not immediately known:
- MakeInvalidArgumentError
- MakeInvalidOperationError
var ErrInvalidError Error
ErrInvalidError is returned when the Error object itself is not valid.
func MakeError ¶
MakeError returns a new Error with the given cause. The returned error contains the current datetime and a stacktrace relative to the time and location MakeError was called.
func MakeFormatError ¶
MakeFormatError returns a new Error with the given cause and formatter. The returned error contains the current datetime and a stacktrace relative to the time and location MakeFormatError was called.
func MakeInvalidArgumentError ¶
MakeInvalidArgumentError returns a new Error with the given cause.
func MakeInvalidOperationError ¶
MakeInvalidOperationError returns a new Error with the given cause.
func UnformatYAML ¶
func (Error) Is ¶
Is reports whether the given error err is equivalent to e.
The given error err is equivalent to e if either of the following are true:
- e.Cause() is equal to err; or
- err is an Error, and e.Cause() is equal to err.Cause().
In other words, Is compares the base errors — Error.Cause — of e and err, and it does not consider the wrapped error chains or the datetime of either.
It must only compare the base errors (i.e., a "shallow" comparison) so that errors.Is can recursively shallow-compare all wrapped errors in a single pass.
The Go doc comment on errors.Is states:
An Is method should only shallowly compare err and the target and not call Unwrap on either.