Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when.spread throws TypeError if argument is non-array #481

Open
ChrisEineke opened this issue Feb 16, 2016 · 3 comments
Open

when.spread throws TypeError if argument is non-array #481

ChrisEineke opened this issue Feb 16, 2016 · 3 comments

Comments

@ChrisEineke
Copy link

when(null).spread();
when(undefined).spread();

leads to a TypeError "Cannot read property 'length' of null", whereas

when(1).spread();

leads to a TypeError "cannot call method 'apply' of undefined".

The errors are a little obtuse. They should indicate that when.spread expects an array when non-array given.

@briancavalier
Copy link
Member

Hi @ceineke, sorry for the confusing error. It should be easy enough to check and provide a more helpful message.

@ChrisEineke
Copy link
Author

I'll be happy to provide a pull request. Do you have your own error class or would you throw Error?

@briancavalier
Copy link
Member

A PR would be awesome, thank you. TypeError actually seems like the right thing to me in this case, so maybe start there and we can see how we feel about it once the PR is up. Sound good?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants