reporting errors with Deferred

31 views
Skip to first unread message

Nick Santos

unread,
May 14, 2013, 11:07:18 AM5/14/13
to closure-lib...@googlegroups.com
When I run a unit test, I usually install a goog.testing.MockClock.

This causes problems for goog.async.Deferred. Deferred uses a
setTimeout to report errors "out-of-band", and the errors get eaten up
by the MockClock.

I can think of a few reasonable ways to fix this. One strawman is to
make a static/global "default" error-handler for Deferred, and make
sure MockClock overrides this method.

Does anybody have strong feelings about this?

Nick

Nate

unread,
May 18, 2013, 4:04:45 AM5/18/13
to closure-lib...@googlegroups.com
Unlike twisted, it would be nice if deferreds erred back with the last exception as a value. like:

addErrback(function(err){
 if(err instanceof Error)...
});

OR...

addCatch/Exceptionback which would always call back with an exception (or list of) that occurred.. 


Nate

Nick Santos

unread,
May 18, 2013, 4:17:26 PM5/18/13
to closure-lib...@googlegroups.com
@nate: closure-library does both of these things, but it's behind a setTimeout.
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Closure Library Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to closure-library-d...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Nate Skulic

unread,
May 18, 2013, 4:59:18 PM5/18/13
to closure-lib...@googlegroups.com
Looking at http://closure-library.go if specifiedoglecode.com/svn/docs/closure_third_party_closure_goog_mochikit_async_deferred.js.source.html#line527 ... Seems like it does neither?  Errors are thrown outside the deferred chain, and there is no way to capture the list of exceptions that occurred in one callback.

What i was suggesting: instead of letting errors get thrown uncaptured; let them be handled by an errback or separate callback. If no errback (or exception callback) specified, simply throw out the exception.


You received this message because you are subscribed to a topic in the Google Groups "Closure Library Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/closure-library-discuss/sucRmy9K_oU/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to closure-library-d...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages