Short answer, most control-flow libraries support grouping and some form of
error coalescing.

Also, you can use stepdown for this. Stepdown supports error coalescing,
and domains for async catching. It also functions by default as an EE as
well:

var $$ = require('stepdown')

function foo(callback) {
  $$([
    function($) {
      var group = $.group()
      urls.forEach(function(url) {
        request.get(url, group())
      })
    }
  ], callback)
}

or...

function foo(callback) {
  var task = $$([
    function($) {
      var group = $.group()
      urls.forEach(function(url) {
        request.get(url, group())
      })
    }
  ])

  task.on('error', callback)
  task.on('complete', callback.bind(null, null))
  return task
}


On Mon, Feb 25, 2013 at 12:00 PM, José F. Romaniello <[email protected]
> wrote:

> quoting docs:
>
> When an EventEmitter instance experiences an error, the typical action is
> to emit an 'error' event. Error events are treated as a special case in
> node. If there is no listener for it, then the default action is to print a
> stack trace and exit the program.
>
>
> 2013/2/25 Glenn Block <[email protected]>
>
>> Jose, thanks for the clarification.
>>
>> Literally right after sending the mail I was thinking I forgot all about
>> event emitters :-)
>>
>> In terms of error, are you saying that any time you emit an event called
>> "Error" the runtime exits if there is no listener?
>>
>>
>>
>>
>> On Mon, Feb 25, 2013 at 3:12 AM, José F. Romaniello <
>> [email protected]> wrote:
>>
>>> +1 on event emitter. Callback with an array of errors is not that common.
>>> You should return an event emitter with complete and error events. be
>>> aware that when you emit an 'error' event and no one is listening in the
>>> application exits
>>>
>>>
>>> 2013/2/25 Pedro Teixeira <[email protected]>
>>>
>>>> Hey Glenn,
>>>>
>>>> For something this complex I think an event emitter may be better
>>>> suited.
>>>>
>>>> --
>>>> Pedro
>>>>
>>>> On Monday, February 25, 2013 at 9:57 AM, Glenn Block wrote:
>>>>
>>>> Hello all
>>>>
>>>> Let's assume you have an API that results in a batch of HTTP calls
>>>> which fire async and which are not sequential. A constraint of the API is
>>>> that any errors that occur during the calls need to get returned to the
>>>> user.
>>>>
>>>> How have you customarily designed this?
>>>>
>>>> One idea was something like the following
>>>>
>>>> function send(message, callback) {
>>>> }
>>>>
>>>> where callback is function(error, results) {
>>>> }
>>>>
>>>> In this case error if not null is a JSON object with a collection of
>>>> child objects with the errors.
>>>>
>>>> An alternative idea I had was to have an additional completion callback
>>>> per item.
>>>>
>>>> so:
>>>>
>>>> function send(message, completionCallback, itemCallback) {
>>>> }
>>>>
>>>> This introduces a callback for each item that is processed. In this
>>>> case the completion callback has a single error if ANY errors occur while
>>>> the   itemCallback has individual errors as they occur.
>>>>
>>>> This is useful for cases where you might want to stop further
>>>> processing if the number of errors is very high.
>>>>
>>>> Thoughts / Experiences?
>>>> Glenn
>>>>
>>>>
>>>>
>>>>  --
>>>> --
>>>> 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 [email protected]
>>>> To unsubscribe from this group, send email to
>>>> [email protected]
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>>>
>>>> ---
>>>> You received this message because you are subscribed to the Google
>>>> Groups "nodejs" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>>
>>>>
>>>>
>>>>  --
>>>> --
>>>> 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 [email protected]
>>>> To unsubscribe from this group, send email to
>>>> [email protected]
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>>>
>>>> ---
>>>> You received this message because you are subscribed to the Google
>>>> Groups "nodejs" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>>
>>>>
>>>
>>>  --
>>> --
>>> 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 [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "nodejs" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>  --
>> --
>> 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 [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "nodejs" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> --
> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Better a little with righteousness
       than much gain with injustice.
Proverbs 16:8

-- 
-- 
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to