stack-slice
Slice a file or directory from the middle of an Error stack trace
why
Sometimes you get an error at a point when you are the middle man, and you want to remove your function from the stack.
usualy if you are a masheling function and dont want to litter the stack with your implementation.
It is too late to use captureStackTrace
thus this allows you to splice your call sites out of the stack.
usage
###stackSlice(error, path[, allowPartialMatch])
var stackSlice = require('stack-slice'),
error = new Error('BANG!!!');
stackSlice(error, '/foo/bar/myCoolModule/main.js');
stackSlice(error, '/foo/bar/myCoolModule/node_modules/someOtherModule', true);
more legitimate use
childModule.run(functionFromParentModule, function(error, result){
if(error){
stackSlice(error, __dirname, true);
return callback(error);
}
callback(null, result);
});