error-stack
Parse and manipulate error.stack
Install
$ npm i error-stack
Usage
const parse = require('error-stack')
const {stack} = new Error('foo')
console.log(stack)
const parsed = parse(stack)
parsed.type
parsed.message
parsed.traces
parsed
.filter(({callee}) => !!callee)
.format()
parsed.type string
Error type
parsed.message string
The message used by Error constructor
parsed.traces Array<Trace>
interface Source {
source: string
line?: number
col?: number
}
interface Trace extends Source{
callee: string
eval?: boolean
evalTrace: Source
}
parsed.filter(filterFunction): this
- filterFunction
Function
the same as the callback function of Array.prototype.filter(callback)
Filters the current traces
parsed.format(): string
Format object parsed
License
MIT