Closed reggi closed 9 years ago
Or Ideally pe.skip
had a this
reference to the entire parsedError
.
Here's a sad implementation
function reverseLines(err, callback) {
var parsedError = new ParsedError(err)
var traceLines = parsedError.trace
var traceLinesSkip = _.chain(traceLines)
.reverse()
.map(function (traceLine, lineNumber) {
traceLine.skip = callback(traceLine, lineNumber)
return traceLine
})
.reverse()
.value()
return function (traceLine, lineNumber) {
return traceLinesSkip[lineNumber].skip
}
}
pe.skip(reverseLines(e, function (traceLine, lineNumber) {
console.log(traceLine.path)
}))
With this
var found = false
pe.skip(reverseLines(e, function (traceLine, lineNumber) {
var after = 'module.js'
var pattern = new RegExp(after)
var match = traceLine.file.match(pattern)
if (match) found = true
return !found
}))
This:
Error: Hello World
at Object.<anonymous> (/Users/thomas/Desktop/node-reggi/z-default-stack.js:49:9)
at Module._compile (module.js:430:26)
at Object.Module._extensions..js (module.js:448:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:471:10)
at startup (node.js:117:18)
at node.js:953:3
becomes this:
Error: Hello World
at Object.<anonymous> (/Users/thomas/Desktop/node-reggi/z-default-stack.js:49:9)
at Module._compile (module.js:430:26)
at Object.Module._extensions..js (module.js:448:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:471:10)
There is an undocumented method called PrettyError::filterParsedError(fn)
. fn
takes a ParsedError
instance and can modify it any way it sees fit.
Feel free to close this issue if you think it has been resolved.
:+1:
Because of the nature of skip, it runs a loop from top (latest) line in the stack to the bottom (earilier) line in the stack. This limited control is preventing me from doing something I think is rather simple.
I'd like to specify a file in a stack and get everything from the first call (last instance) up.
So given this stack of addrs.
If I specify
beta.js
I'd like to skipalpha.js
.I have this working here.
Where this fails is if beta is called twice in the stack
This function will return
instead of this, which is my desired result.
If there was a
skipReverse
function I could do this pretty easily. Is there any way to do this?