Documentation
¶
Overview ¶
Package errs provides error handlers for functions.
The purpose of the errs (short for error handler) package is to provide an error handler base for functions that might encounter errors which they do not know what to do with.
For example, there are many valid ways to respond to an error when processing a directory of files. You might want to ignore them, print them, handle them specially depending on the error.
When writing a function that takes an error handler, allow the user to set a default handler and then pass in nil to specify that the default is desired:
func ACME(h errs.Handler, args ...interface{}) error { errs.Init(&h) ... if err = h(err); err != nil { return err } ... return nil }
Additionally, the MultipleErrors type is provided to wrap multiple errors, in case no error handler is desired.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init(h *Handler)
Init is called by functions that take an Handler to make sure that an Handler is in fact available. It is usually valid to provide functions that expect an Handler a nil, because this function replaces that value with the default Handler, which you can set yourself.
Types ¶
type Collector ¶
Collector collects multiple errors and returns a MultipleError if any of the errors are non-nil.
func NewCollector ¶
func (*Collector) Add ¶
Add adds err to the list of errors, without checking whether it is nil or not.
type Handler ¶
Handler is used by many functions to deal with errors, most of which will be nil errors.
There are several Handlers already available for use. Most functions expect that you return nil. Program functionality may be impaired otherwise.
Default is the default Handler that should be used when nil is supplied, see AssertHandler.
func Bundle ¶
Bundle bundles all received errors into an ErrorList, which you have to supply (as el).
type MultipleError ¶
func (*MultipleError) Error ¶
func (e *MultipleError) Error() string