Created
March 5, 2015 21:49
-
-
Save davidcalhoun/59d8f7d15835938baff6 to your computer and use it in GitHub Desktop.
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
// one: passes up the error from two() | |
function one(cb){ | |
two(function(err, data){ | |
if(err) return cb('one ' + err); | |
return cb(null, data); | |
}); | |
} | |
// two: passes up the error from three() | |
function two(cb){ | |
three(function(err, data){ | |
if(err) return cb('two ' + err); | |
return cb(null, data); | |
}); | |
} | |
// three: always returns an error | |
function three(cb){ | |
cb('three: something bad happened'); | |
} | |
// kick off one(), log the inevitable error with a simple function trace | |
one(function(err, data){ | |
if(err) { | |
console.log(err); | |
return; | |
} | |
}); | |
// output: | |
// one two three: something bad happened |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment