briancavalier/when.js — Issue #15: fail early and loudly when attempting to register a handler that's not a function
Author: briancavalier
Created: 2012-01-13 02:24:55+00:00
State: open

Right now, if you accidentally pass something that's not a function as the callback, errback, or progback to `.then()`, `when()`, or any other method that accepts handlers, it may fail silently later when the promise is resolved, rejected, or progressed. Even if the failure does get logged, the accompanying stack trace might be useless if the resolution/rejection/progress occurs in a different event loop turn.

This could become an even bigger debugging headache if we start forcing future-turn resolutions, see #12.

This may be more likely to folks who use `when.all/some/any()`, and who may have used jQuery Deferred and `$.when`. Since `when.all()`'s second parameter, for example must be a function, and `$.when()`'s second parameter is allowed to be another deferred, some folks may be inclined to write:

```javascript
when.all(promise1, promise2).then(doSomething);
```

which may fail silently. It should be written as:

```javascript
when.all([promise1, promise2]).then(doSomething);
// or
when.all([promise1, promise2], doSomething);
```