trying to get a stack trace working lol
This commit is contained in:
29
index.js
29
index.js
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user