cujojs / when

A solid, fast Promises/A+ and when() implementation, plus other async goodies.
Other
3.44k stars 396 forks source link

Fix unhandled rejection reporting for null errors #412

Closed Feasul closed 9 years ago

Feasul commented 9 years ago

In case promise is rejected with a 'null' and unhadled rejection is reported check for error type fails in 'formatError' method. The reason for it is that 'typeof null' is also an 'object' (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof).

Therefore an additional check for 'e' to also not be a 'null' is added to 'formatError' method code.

briancavalier commented 9 years ago

Great catch! You've also reminded me that I need to move those format helpers to their own module so they can actually be unit tested :)

briancavalier commented 9 years ago

Extracted them in this branch: https://github.com/cujojs/when/tree/extract-format-module

Need to write a few unit tests for them now.

briancavalier commented 9 years ago

This just landed in 3.6.4. Thanks again!

Feasul commented 9 years ago

Was glad to help. When is a great library.