Add and use predicates of the promise's current state.
Make .then(ok, no) == .then(ok).fail(no)
Don't swollow exceptions in failFn or treat its result as success.
whenResolved
Improved failure handling

- onFail will always be triggered if it is specified together with or after onSuccess which raises an exception
- if onFail returns a promise the error state can be recovered from. Other return values are ignored and the original failure propagates
- if onSuccess and onFail are specified together and onFail returns a promise, the onSuccess function will be chained onto the new promise before this promise is resolved, thereby recreating the original promise chain
Merge pull request #1 from xnlogic/handle-errors

Handle errors