Ok, I can understand that it is important the ability to resume (or not) resolving after catching exceptions.
The problem with the current solution is that without handling exceptions, the resume feature by
done() easily induces unpredictable behaviors, making debugging considerably harder.
You are not understating the problem or you do not consider it a big deal or I am missing something. If so, I would like to have an explanation.
I can understand (and agree) that my previous solutions are not ideal (A and B because resuming is performed even after not caught exceptions; C because it removes the resume feature).
Hoverer, it doesn't mean that there is not an better solution, and I think I have one (hm, lets call it Solution D).
To handle exceptions, the producer has to override/wrap the
resolveWith() function (your examples was not enough because not handling next
done() calls). See example:
http://jsfiddle.net/D4jvh/6/.
Now, that works, having the precaution to always call
cancel() or
done(), because otherwise the behavior will be unpredictable (because of the "auto resume feature") but it is not a big deal. The real problem, is when the exception is not handled at all (as I said).
To resolve both, we can make resuming an explicit operation, introducing an
resume() method, and remaining in the
firing state until that method is not called.
But it is not all! We now can remove the
try/finally construct completely, avoiding the need to insert the
catch block to avoid the IE6/7 bug. So the solution D would be something like
https://gist.github.com/828650 and the previous example would be replaced with this one:
http://jsfiddle.net/D4jvh/7/.
Note how in this one we don't need to call
cancel(), that can be important in cases where there is no such method (
Deferred).
Now, with the new
_Deferred, the first test would output "A !" (
http://jsfiddle.net/2Mbfn/3/), where resuming is halted even in case of an asynchronous
done().
If there is no objections, I would like to fill some related bug reports and to submit a patch + pull request.
TL DR; Resuming the resolving should be explicit.