get extension method, handling errors
Closed this issue · 4 comments
Sample code:
var deferred = require('deferred');
deferred(null).get('a').then(console.log, function() { console.log('an error happened'); });
Currently it throws an exception (TypeError: Cannot read property 'a' of null). I think it should fail the promise instead.
This case applies to the invoke method as well.
@alexbft on which version of deferred you're working?
Latest deferred works as expected:
$ node
> var deferred = require('deferred');
undefined
> deferred(null).get('a').then(console.log, function() { console.log('an error happened'); });
an error happened
Maybe some older version have such logic error. Let me know.
I've looked into history, it was fixed with 0.5.0.
If you're not sure about switching from 0.4 to 0,5 check CHANGES document for all changes information (it however missed information about that fix, I've added it now)
Yeah, it was version 0.4.3. Thanks!
You're welcome.
I've just found that we still had similar issue with invoke
extension (for null or undefined context). I've fixed it and updated deferred to v0.5.1 version