From the course: Advanced Node.js
Unlock the full course today
Join today to access over 24,200 courses taught by industry experts.
Rejecting promises - Node.js Tutorial
From the course: Advanced Node.js
Rejecting promises
- [Instructor] In the last lesson, we introduced the Promise object and saw how it could be used to handle asynchronous code. What we didn't implement with this Promise object is what happens if something goes wrong. So within the Promise itself, we get to send it the code that it will invoke and anywhere this code can cause an error. I can actually throw a new error and we'll call this error ar. So let's just assume that an error happens anywhere within our Promise. That means when we come over here to run the code, I do note that, oh, we see an error. Well that makes sense because we threw an error. Let me go ahead and drag this out so we can see this full error here. What you'll notice is we see an unhandled Promise rejection, that means that an error has occurred within a Promise but we didn't handle it. If I look at this Promise that I invoked in the last lesson, we can see several then methods but there is nothing here to handle an error. Within Promises, we can handle the error…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Callback pattern8m
-
(Locked)
Resolving promises5m 40s
-
(Locked)
Rejecting promises2m 58s
-
(Locked)
The promisify function5m 18s
-
(Locked)
Sequential execution7m 6s
-
(Locked)
Sequential execution with async/await7m
-
(Locked)
Parallel execution4m 6s
-
(Locked)
Concurrent tasks6m 3s
-
(Locked)
Logging concurrent tasks3m 3s
-
-
-
-