-
Notifications
You must be signed in to change notification settings - Fork 33.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
async & performance/ch3 - Promise: a confusing part - reject vs throw not covered #961
Comments
i test the example, find th is still resolve , but the "throw" will be throw to global(tips: Uncaught (in promise) test) |
@memoryza i tested in node v6.9.1:
I seemed that th is was pending forever, hanged on. And the err throwed was NOT promise-catched |
This is pretty much the main reason for needing the |
@getify thanks for reply. I understand your meaning. But could you please explain the first example: sometimes they behavior the same? Could we conclude that they are the same in synchronous env, and different in async env, when used in promise context? |
I would always use |
I've red this chapter, tried some example and found that sometime
throw
can be used instead ofreject
, for example, the following 2 promises has the same result:Both can be catched and output the same error:
But other times
throw
andreject
behavior terribly different:I can't find the answer in this chapter. So am i missing something or we should cover this confusing part?
I googled it and not found something clearly explain this point.
The text was updated successfully, but these errors were encountered: