proposal: bindAll should throw a reference error if a given method is undefined#1692
proposal: bindAll should throw a reference error if a given method is undefined#1692michaelficarra merged 3 commits intojashkenas:masterfrom
Conversation
…e incoming object
|
|
|
it's not currently using bind. That seems to have changed about 2 weeks ago with this commit by @megawac Even still, it would be nice to get the name of the offending function as bind only gives you "Bind must be called on a function" and there can be many functions given to bindAll at once... |
I'm aware of that. Adding extraneous error code is a slippery slope. We should leverage the error handling that exists without going overboard. Simply replacing |
|
I definitely agree with reverting to using |
…o ensure that errors are thrown for invalid input
proposal: bindAll should throw a reference error if a given method is undefined

If a given method is undefined, createCallback is going to return a function that will eventually throw an error when it is called. This is because createCallback returns a function that will evaluate to undefined.apply. If that's true, then it would be nice to catch these errors when we do the binding instead of when we call the unusable functions.
Here's an example...
https://gist.github.com/smarden1/b08f84fd3b1c363d403d
Additionally, I like getting the erroneous method name in my exception as bindAll can take a long list of functions and hunting down the erroneous one in that list is a bummer.