Skip to content

Instantly share code, notes, and snippets.

@bttmly
Created May 12, 2016 18:25
Show Gist options
  • Save bttmly/431fbd6d1585a28d34e3647d87272484 to your computer and use it in GitHub Desktop.
Save bttmly/431fbd6d1585a28d34e3647d87272484 to your computer and use it in GitHub Desktop.
demonstration of Error.captureStackTrace
function Miss () {
return new Error("My stack trace is wrong");
}
function Hit () {
var err = new Error("My stack trace is right");
Error.captureStackTrace(err, Hit);
return err;
}
function errDeeply (Err) {
(function fn1 () {
(function fn2 () {
(function fn3 () {
console.log(new Err().stack)
})()
})()
}())
}
errDeeply(Miss):
errDeeply(Hit);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment