Documentation
¶
Overview ¶
Package multierror defines an error Accumulator to contain multiple errors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReplaceNewlines ¶
ReplaceNewlines collapses an error's message into a single line. Using this as a FilterAccumulator.Filter helps when accumulating errors for systems that split log reports on line boundaries (like loggly).
Types ¶
type Accumulator ¶
type Accumulator []error
Accumulator is an error accumulator.
Usage:
var errors multierror.Accumulator errors.Push(returnsErrOrNil()) errors.Push(returnsErrOrNil()) errors.Push(returnsErrOrNil()) return errors.Error()
func (*Accumulator) Error ¶
func (m *Accumulator) Error() error
Error returns the accumulated errors. If no errors have been pushed onto the accumulator, then nil will be returned. If only a single error has been pushed onto the accumulator, it is returned directly.
Note that Accumulator can't implement the error interface directly because of http://golang.org/doc/faq#nil_error. That is, return a nil Accumulator as an error interface would result in a non-nil error to a nil Accumulator.
func (*Accumulator) Push ¶
func (m *Accumulator) Push(err error)
Push adds an error to the Accumulator. If err is nil, then Accumulator is not affected.
func (*Accumulator) PushWithf ¶
func (m *Accumulator) PushWithf(fmtstr string, err error, args ...interface{})
PushWithf adds a formatted error string to m if err is non-nil. err is passed as the first argument to fmtstr, and any additional arguments in args are passed as the remaining arguments.
func (*Accumulator) Pushf ¶
func (m *Accumulator) Pushf(fmtstr string, args ...interface{})
Pushf adds a formatted error string to the Accumulator. It is a shortcut for Push(fmt.Error(...)).
func (Accumulator) String ¶
func (m Accumulator) String() string
String prints the accumulated errors or "nil" if no errors have been pushed.
type ConcurrentAccumulator ¶
type ConcurrentAccumulator struct {
// contains filtered or unexported fields
}
ConcurrentAccumulator is a thread-safe accumulator that can be used across many goroutines.
func (*ConcurrentAccumulator) Error ¶
func (c *ConcurrentAccumulator) Error() error
func (*ConcurrentAccumulator) Push ¶
func (c *ConcurrentAccumulator) Push(err error)
func (*ConcurrentAccumulator) Pushf ¶
func (c *ConcurrentAccumulator) Pushf(fmtstr string, args ...interface{})
type FilterAccumulator ¶
type FilterAccumulator struct {
// Filter is a client-provided function that, given a (possibly-nil)
// error, returns a transformed error. Filter is allowed to suppress an
// error by returning nil.
Filter func(err error) error
Accumulator
}
FilterAccumulator allows
func (*FilterAccumulator) Push ¶
func (a *FilterAccumulator) Push(err error)
func (*FilterAccumulator) Pushf ¶
func (a *FilterAccumulator) Pushf(fmtstr string, args ...interface{})