-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Handling of errors in find & some #1248
Comments
I think exiting immediately on an error is the "correct" thing to do here. If the error occurred on the iteration loop that called-back |
Sure, but in
No that's definitely counted as an error. When checking an individual callback, error should always takes precedence over the rest of the resolve arguments. |
Ah, I see, there could be some race conditions in the parallel case, or there could be conflicting results in the parallel case. Not sure what the correct thing to do is. Consider this example: _.some(_.range(10), function (num) {
if (num > 5) throw new Error();
return num === 5;
} This won't throw with Lodash, but that is just an artifact of its short-circuiting. But should it? Half the values would throw an error if they were iterated over. If it were iterated in reverse, it would throw every time, even though the I'm trying to think of a real world example with Async. Would you want to know that one of your iteration steps produced an error, even if the |
Related #591 |
Hmnn, this has been open for a long time, and I'm not convinced it's still an issue now that we have |
Upon some reflection I don't like how we handle errors in the internal
createTester
.When an error occurs we resolve the callback resolves immediately; however, if in the case of some or detect, if the iteratee returned truthy we would have exited
createTester
successfully.I think the correct approach would be to continue upon error and determine whether any item was truthy.
The text was updated successfully, but these errors were encountered: