tildeio/rsvp.js — pull request #88 by drogus (2013-06-23 11:04:23+00:00)
Title: [WIP] Implement done()

I've started work on `done()` implementation, which would tell the promise that the chain is stopped. It will be useful in places where you want to stop catching errors in callbacks, especially in libraries. For example right now we can do something like this:

```javascript
functionReturningApromise().then(userSuccessCallback, userFailureCallback).
then(null, function(error) {
console.log('there was an error while processing your callbacks:', error);
});
```

This is not optimal, because you loose the stack trace and you can't easily set debugger to break on unhandled exception to check what's going on. Instead you would need to set debugger to stop on any exception, which is harder to do - typically there are at least a few exceptions thrown around.

What would be better is:

```javascript
functionReturningApromise().then(userSuccessCallback, userFailureCallback).done();
```

In such case if there is any error in `userSuccessCallback` or in `userFailureCallback`, the exception will be thrown and user will immediately see the problem.

The implementation here is just a start, I'm pretty sure that it's not complete, but I would like to get a feedback on this feature proposal and also ask about sane way to write tests for it. I've implemented a simple `catchExceptions` function, which will catch exceptions in asynchronous code, but it fails in the browser part without much info on what's going on. Is there any better way to do this?

I will appreciate any feedback.