Documentation ¶
Index ¶
- Variables
- func Append(to, err error) error
- type FormatterFunc
- type MError
- func (me *MError) Append(errs ...error)
- func (me *MError) As(target interface{}) bool
- func (me *MError) Error() string
- func (me *MError) ErrorOrNil() error
- func (me *MError) Errors() []error
- func (me *MError) Is(target error) bool
- func (me *MError) Len() int
- func (me *MError) Overflow() int
- func (me *MError) SetFormatter(f FormatterFunc) (old FormatterFunc)
Constants ¶
This section is empty.
Variables ¶
var GlobalFormatter = defaultFormatter
GlobalFormatter is the global merror formatter. Set this to a custom formatter if desired.
Functions ¶
Types ¶
type FormatterFunc ¶
FormatterFunc is a function that converts a merror to a string.
type MError ¶
type MError struct {
// contains filtered or unexported fields
}
MError represents zero or more errors that can be accumulated via the `Append` method.
func New ¶
func New() *MError
New returns a new instance of `MError` with no limit on the number of errors that can be appended.
func NewWithCap ¶
NewWithCap returns a new instance of `MError` with a maximum capacity of `cap` errors. If exceeded only the overflow counter will be incremented.
A `cap` of zero of less means no cap and max size of a slice on the current platform is the upper bound.
func (*MError) Error ¶
Error returns a string representation of this MError. The output format depends on the `Formatter` set for this merror instance, or the global formatter if none set.
func (*MError) ErrorOrNil ¶
ErrorOrNil returns nil if this `MError` contains no errors, otherwise this `MError` is returned.
func (*MError) Errors ¶
Errors returns a slice of the `error` instances that have been appended to this `MError`.
func (*MError) Overflow ¶
Overflow returns the number of errors that have been truncated because maximum capacity was exceeded.
func (*MError) SetFormatter ¶
func (me *MError) SetFormatter(f FormatterFunc) (old FormatterFunc)
SetFormatter sets the `FormatterFunc` to be used when `Error` is called. The previous `FormatterFunc` is returned.