Documentation
¶
Overview ¶
Package errors provides helper functions and structures for more natural error handling in some situations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsEx ¶
Convert an error to an exception. This function doesn't do anything with nil errors and errors which are already exceptions.
Types ¶
type ErrorList ¶
type ErrorList struct {
// contains filtered or unexported fields
}
An error which is a list of errors. It's intended to be used locally in a function to aggregate errors from different calls. Here is a typical use case:
type aggregator struct {
val1 io.Closer
val2 io.Closer
vals []io.Closer
}
func (self *aggregator) Close() error {
errs := errors.List().
Add(self.val1.Close()).
Add(self.val2.Close())
for _, v := range self.vals {
errs.Add(v.Close())
}
return errs.Err()
}
func AsList ¶
Create an error list from errors. Nil errors and other error lists are added as in Add.
func (*ErrorList) Add ¶
Add an error to the list. This function ignores nil errors and inlines other error lists so that you don't have error lists of error lists.
func (*ErrorList) AddAll ¶
Add all errors from the array to the error list. Nil errors and other error lists are added as in Add.