Created
March 13, 2018 16:25
-
-
Save victor-shepardson/a4afb8646809fcf64268bbf792aec5b5 to your computer and use it in GitHub Desktop.
demonstrate that `.catch(err => Promise.reject(err))` is redundant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
(new Promise((resolve, reject) => { | |
resolve('success'); | |
})).then(x => {throw 'thrown error in then, no catch'}); | |
(new Promise((resolve, reject) => { | |
resolve('success'); | |
})).then(x => {throw 'thrown error in then, with catch'}) | |
.catch(err => Promise.reject(err)); | |
// both result in UnhandledPromiseRejectionWarning | |
// (node 6.12.3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment