Closed davepacheco closed 7 years ago
For reviewers interested in seeing these in action:
This change is make prepush
clean on SmartOS 32-bit node v0.10.46. I don't expect these changes are OS-dependent, data-model-dependent, or version-dependent.
I'm using errorForList
in icedfrisby. Thanks!
Cool!
I've found it useful to have a pair of functions for working with MultiErrors:
errorForList(list)
: construct a MultiError from the array of errorslist
, but iflist
is empty, returnsnull
, and iflist
has only one element, returns that error directly. In this way, given any number of errors accumulated during an operation, this function returns an appropriate single error to summarize the result.errorForEach(err, func)
: given a normal error, invokesfunc(err)
, but given a MultiError, invokesfunc(errorN)
for each error underlying theMultiError
. I've found this useful for operations that accumulate warnings that may or may not be encapsulated with a MultiError.