Skip to content

Instantly share code, notes, and snippets.

@denizozger
Created August 5, 2016 12:16
Show Gist options
  • Save denizozger/13274a4da749a25445faa862de08b38b to your computer and use it in GitHub Desktop.
Save denizozger/13274a4da749a25445faa862de08b38b to your computer and use it in GitHub Desktop.
Demonstrate why Error()'s are useless when callback queue is used
var getValue = function(value, cb) {
setTimeout(function err() {
throw Error();
}, 0);
return cb(null, value);
};
var result = getValue(5, (err, a) => {
console.log(a);
});
process.exit();
// Output :5
var getValue = function(value, cb) {
throw Error();
return cb(null, value);
};
var result = getValue(5, (err, a) => {
console.log(a);
});
process.exit();
// throws Error()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment