You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Greetings!
I've stumbled upon some thing I can't comprehend.
It is said at the end of lesson's description:
If you are not returning a value from your promise to a caller,
then attach a done handler to guard against uncaught exceptions.
And in #bonus sections:
Try swapping your rejection handler from console.log to alwaysThrows.
Your program will now throw an exception in the global context! Ahh!
Try to fix this using the approach described above.
My code:
function alwaysThrows() {
throw new Error("OH NOES");
}
function iterate(integer) {
console.log(integer);
return integer+1;
}
Promise.resolve( iterate(1) )
.then( v => Promise.resolve( iterate(v) ))
.then( v => Promise.resolve( iterate(v) ))
.then( v => Promise.resolve( iterate(v) ))
.then( v => Promise.resolve( iterate(v) ))
.then( v => alwaysThrows() )
.then( v => Promise.resolve( iterate(v) ))
.then( v => Promise.resolve( iterate(v) ))
.then( v => Promise.resolve( iterate(v) ))
.then( v => Promise.resolve( iterate(v) ))
.then( v => Promise.resolve( iterate(v) ))
// .catch( e => console.warn(e) )
.catch( e => alwaysThrows() )
.done( console.log )
The problem with .done() method of Promise interface. Node refuses to run this code. I looked through MDN articles,etc. but found nothing like .done(). It seems like this method doesn't exist.
Btw, this method exists in Q library...
Could someone please explain what's wrong with my code. Sorry if my question bothers anyone, im just learning.
Thanks in advance
The text was updated successfully, but these errors were encountered:
mcompote
changed the title
#11 Multiple promises | #bonus part
#10 Multiple promises | #bonus part
Jan 11, 2018
mcompote
changed the title
#10 Multiple promises | #bonus part
#10 An important rule | #bonus part
Jan 11, 2018
Greetings!
I've stumbled upon some thing I can't comprehend.
It is said at the end of lesson's description:
And in #bonus sections:
My code:
The problem with .done() method of Promise interface. Node refuses to run this code. I looked through MDN articles,etc. but found nothing like .done(). It seems like this method doesn't exist.
Btw, this method exists in Q library...
Could someone please explain what's wrong with my code. Sorry if my question bothers anyone, im just learning.
Thanks in advance
The text was updated successfully, but these errors were encountered: