It depends on your requirements, but here are some quick thoughts.

If you are using callbacks you typically only want to call the callback 
once so:

Many systems just return the first error that occurs and you would be 
expected to resolve and then retry the operation.

If you actually want all the errors, then you would need to wait for 
everything to complete or fail and then return an error for the collection 
and you could attach the other errors to it for reference.

For example 

// wait for everything to finish or error
var errCollection = new Error('this could be concat of error strings or 
just generic msg mentioning the collection in .errors');
errCollection.errors = [ err1, err2, err3]; // add the errors as property 
so it can be used by code or for enhanced debugging
cb(errCollection); // make the final callback



If you are using events then you could just emit errors as they happen. 
Multiple error events is fine.

If using streams, then it is like a callback in that you only want to emit 
one error.


On Thursday, 5 July 2012 10:44:45 UTC-5, Alan Gutierrez wrote:
>
> Let's say that somewhere within your library, you delete the contents of a 
> directory in parallel. Let's say all the files in a  directory are 
> read-only so 
> all your parallel requests return an error. 
>
> If you've exposed a Node.js style asynchronous function with an `(error, 
> result, 
> result...)` callback, how do you report multiple errors to person who 
> called 
> your library? Do you wrap the multiple errors in a single error, maybe 
> having an 
> array of `causes`? Do you note that multiple errors may be returned? 
>
> Are the functions in the Node.js API that might return more than one error 
> that 
> I could study? Do any of the event emitters in the Node.js API emit a 
> series of 
> errors, or is it just one error prior to entering an error state? 
>
> -- 
> Alan Gutierrez - http://twitter.com/bigeasy - http://github.com/bigeasy 
>

On Thursday, 5 July 2012 10:44:45 UTC-5, Alan Gutierrez wrote:
>
> Let's say that somewhere within your library, you delete the contents of a 
> directory in parallel. Let's say all the files in a  directory are 
> read-only so 
> all your parallel requests return an error. 
>
> If you've exposed a Node.js style asynchronous function with an `(error, 
> result, 
> result...)` callback, how do you report multiple errors to person who 
> called 
> your library? Do you wrap the multiple errors in a single error, maybe 
> having an 
> array of `causes`? Do you note that multiple errors may be returned? 
>
> Are the functions in the Node.js API that might return more than one error 
> that 
> I could study? Do any of the event emitters in the Node.js API emit a 
> series of 
> errors, or is it just one error prior to entering an error state? 
>
> -- 
> Alan Gutierrez - http://twitter.com/bigeasy - http://github.com/bigeasy 
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to