Skip to content

Unexpected error in Promise.loop() #23

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

Open
dbukhmastov opened this issue Mar 1, 2017 · 4 comments
Open

Unexpected error in Promise.loop() #23

dbukhmastov opened this issue Mar 1, 2017 · 4 comments

Comments

@dbukhmastov
Copy link
Contributor

Reject handler invokation is expected.

Scenario:
Promise.loop(true, @() Promise(function (resolve, reject) { resolve(2) }))
.then(function(res) {
server.log("Resolve handler is called " + res);
}, function(res) {
server.log("Reject handler is called " + res);
})

Log:
2017-03-01 16:22:49+0000 [Agent] ERROR: attempt to call 'bool'
2017-03-01 16:22:49+0000 [Agent] ERROR: in unknown ...ricimp#promise.class.nut#3.0.0:191

@dbukhmastov dbukhmastov changed the title Unexpexted error in Promise.loop() Unexpected error in Promise.loop() Mar 1, 2017
@ppetrosh
Copy link

ppetrosh commented Mar 2, 2017

To be honest, I don't think this is something that needs to be fixed. Even if we add checks for the first parameter type, you can still fail even if you pass a function (on a wrong number of arguments, that it has). My $.02.

@dbukhmastov
Copy link
Contributor Author

I think that the behavior (when params is wrong) should be the same for all(), loop(), serial() and race() methods. For me: The reject(fail) handler should be called as in Promise.all().

@ppetrosh
Copy link

ppetrosh commented Mar 2, 2017

What happens in this case in JavaScript? Did you try that?

@dbukhmastov
Copy link
Contributor Author

Not yet

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