Skip to content

Instantly share code, notes, and snippets.

@victor-shepardson
Created March 13, 2018 16:25
Show Gist options
  • Save victor-shepardson/a4afb8646809fcf64268bbf792aec5b5 to your computer and use it in GitHub Desktop.
Save victor-shepardson/a4afb8646809fcf64268bbf792aec5b5 to your computer and use it in GitHub Desktop.
demonstrate that `.catch(err => Promise.reject(err))` is redundant
'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