[mochikit] Re: deferred callbacks that throw errors

2008-01-24 Thread SimonS

  Is there a simple way to abort the callback chain from one of the
  callbacks?

 It continues calling the success chain because the errback doesn't
 return an error or raise an exception.

Thanks - I tried throwing an exception from the errback as you suggest
and it does what I want (stops further success callbacks happening).

Cheers,

Simon.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
MochiKit group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~--~~~~--~~--~--~---



[mochikit] Re: deferred callbacks that throw errors

2008-01-23 Thread Bob Ippolito

On Jan 23, 2008 9:07 PM, SimonS [EMAIL PROTECTED] wrote:

 Hi,

 I'm curious about the effect of the following code:

   var d  = new Deferred();
   d.addCallback(function() { alert('f');  throw new
 GenericError('foo'); });
   d.addErrback(function() { alert('e'); });
   d.addCallback(function() { alert('s'); });
   d.callback('success');

 The result I observe is that all three alerts fire, in the order 'f',
 'e', 's'.  This happens even though the first callback (f) throws an
 exception.  My question is why is the last alert fired?

 The docs say that a callback that throws an exception will put the
 deferred into an error state.  Since the deferred transitions to an
 error state, why does it continue calling the 'success' chain?

 Is there a simple way to abort the callback chain from one of the
 callbacks?

It continues calling the success chain because the errback doesn't
return an error or raise an exception.

-bob

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
MochiKit group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~--~~~~--~~--~--~---