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

Potential typo in 11 - Promises - Node.js Rejection Handling #455

Open
ronen-e opened this issue Sep 20, 2020 · 0 comments
Open

Potential typo in 11 - Promises - Node.js Rejection Handling #455

ronen-e opened this issue Sep 20, 2020 · 0 comments

Comments

@ronen-e
Copy link
Contributor

ronen-e commented Sep 20, 2020

Where
Chapter 11 - Promises, under Node.js Rejection Handling

let rejected;

process.on("unhandledRejection", function(reason, promise) {
    console.log(reason.message);            // "Explosion!"
    console.log(rejected === promise);      // true
});

rejected = Promise.reject(new Error("Explosion!"));

Problem

This example creates a rejected promise with an error object and listens for the unhandledRejection event.

Reason
It is not clear that the error object is the promise value

Solution

This example creates a rejected promise with an error object as its value and listens for the unhandledRejection event.

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

1 participant