Documentation ¶
Overview ¶
Package errutil provides utilities for working with errors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CollectErrors ¶
CollectErrors creates a MultiError from the given errors and returns its error representation (AsError). If there are no non-nil errors it returns nil, if there's exactly one error, it is returned and if there are more errors the MultiError is returned.
Types ¶
type MultiError ¶
type MultiError []error
MultiError is a slice of errors which itself implements the Error interface. A MultiError may contain nil errors.
func (MultiError) AsError ¶
func (e MultiError) AsError() error
AsError returns nil if the normalised MultiError is empty, the only error if there's exactly one error and otherwise it returns the normalised version of itself.
func (MultiError) Error ¶
func (e MultiError) Error() string
func (MultiError) Normalize ¶
func (e MultiError) Normalize() MultiError
Normalize removes all instances of nil from the MultiError and flattens nested MultiError instances.
func (MultiError) Strings ¶
func (e MultiError) Strings() []string
Strings returns a slice of all error strings in the MultiError. This does not use a normalized version of the MultiError.