Asked by:
once again: done vs then

General discussion
-
Hello guys.
I thought I understood the difference between done and then, but now I'm having some doubts about the exception handling. The docs say the following:
Unhandled exceptions in a then function are silently captured as part of the state of the promise, but unhandled exceptions in a donefunction are thrown. Both functions can handle exceptions that have been passed to them as part of the state of a promise.
However, I've noticed that if you don't pass an error method to the then, then the runtime will end up throwing the exception. so, can someone explain (probably with a simple example) what the previous setence means?
thanks.
Luis Abreu
Tuesday, June 26, 2012 10:58 AM
All replies
-
just putting it on the top again :)
Luis Abreu
Wednesday, June 27, 2012 11:19 AM -
can someone help?
thanks.
Luis Abreu
Monday, July 2, 2012 8:36 PM -
Then returns a Promise whereas Done does not. That is the difference. Done throws exceptions because it is just like any old function.Monday, July 2, 2012 9:23 PM
-
Hi Luis.
You can chain up your THEN , and end the chain with a Done.
I believe the behaviour is , exception will be thrown if you have no Done after the last Then.Reason being , if developers don't use Done , then they will never see the exception. I think the doc is just there to encourage people to use Done.
So yes, the document is not accurate in this case.
Monday, July 2, 2012 11:19 PM -
hello guys.
The problem here is not getting a reference to a Promise. the thing is that the docs say that then will swallow the exception. As I said, I've noticed that there are some times where then does not swallow the exception.
I think I've understood the problem, but can't comment on it yet. lets wait for an official answer from MS.
Luis Abreu
Tuesday, July 3, 2012 8:12 AM -
Done won't swallow an exception. Only the functions that return a promise swallow exceptions.Tuesday, July 3, 2012 11:37 AM
-
Yes, that is true. the same happens when you use then (at least, with a some types of promise)
Luis Abreu
Tuesday, July 3, 2012 11:33 PM