2.0.5 • Published 7 months ago
error-stack2 v2.0.5
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)
// Error: foo
// at repl:1:11
// at Script.runInThisContext (vm.js:123:20)
const parsed = parse(stack)
parsed.type // Error
parsed.message // foo
parsed.traces
// [
// {
// callee: undefined,
// source: 'repl',
// line: 1,
// col: 11
// },
// {
// callee: 'Script.runInThisContext',
// source: 'vm.js',
// line: 123,
// col: 20
// }
// ]
parsed
.filter(({callee}) => !!callee)
.format()
// Error: foo
// at Script.runInThisContext (vm.js:123:20)
parsed.type string
Error type
parsed.message string
The message used by Error constructor
parsed.traces Array<Trace>
interface Source {
// The source of the the callee
source: string
line?: number
col?: number
}
interface Trace extends Source{
callee: string
// Whether the callee is 'eval'
eval?: boolean
// The source location inside eval content
evalTrace: Source
}
parsed.filter(filterFunction): this
- filterFunction
Function
the same as the callback function ofArray.prototype.filter(callback)
Filters the current traces
parsed.format(): string
Format object parsed
License
2.0.5
7 months ago
2.0.3
2 years ago
2.0.4
2 years ago
1.0.18
2 years ago
1.0.17
2 years ago
2.0.2
2 years ago
1.0.15
2 years ago
1.0.14
2 years ago
2.0.1
2 years ago
1.0.13
2 years ago
1.0.11
3 years ago
1.0.10
3 years ago
1.0.9
3 years ago
1.0.8
3 years ago
1.0.7
3 years ago
1.0.12
3 years ago
1.0.6
3 years ago
1.0.5
3 years ago
1.0.4
3 years ago