trying to get a stack trace working lol

This commit is contained in:
Ben
2018-09-08 12:26:34 +01:00
parent 301f255d0d
commit 30a1e1e834
3 changed files with 823 additions and 4 deletions

View File

@@ -3,4 +3,33 @@ require('babel-register')({
presets: [ 'env' ]
});
function temporaryPrepare() {
return arguments[1];
}
function globalStack() {
const orig = Error.prepareStackTrace;
Error.prepareStackTrace = temporaryPrepare;
const err = new Error;
Error.captureStackTrace(err, globalStack);
const stack = err.stack;
Error.prepareStackTrace = orig;
return stack;
}
Object.defineProperty(global, "__stack", {
get: globalStack
});
Object.defineProperty(global, "__line", {
get() {
return __stack[1].getLineNumber();
}
});
Object.defineProperty(global, "__function", {
get() {
return __stack[1].getFunctionName();
}
});
module.exports = require('./src/app');