| 1 | error-stack-parser.js - Extract meaning from JS Errors
|
|---|
| 2 | ===============
|
|---|
| 3 | [](https://github.com/stacktracejs/error-stack-parser/actions?query=workflow%3AContinuous+Integration+branch%3Amaster)
|
|---|
| 4 | [](https://coveralls.io/r/stacktracejs/error-stack-parser?branch=master)
|
|---|
| 5 | [](https://opensource.org/licenses/MIT)
|
|---|
| 6 | [](https://github.com/stacktracejs/error-stack-parser/releases)
|
|---|
| 7 | [](https://github.com/stacktracejs/error-stack-parser/releases)
|
|---|
| 8 | [](https://github.com/stacktracejs/error-stack-parser/releases)
|
|---|
| 9 | [](http://todogroup.org/opencodeofconduct/#stacktrace.js/me@eriwen.com)
|
|---|
| 10 | [](https://www.jsdelivr.com/package/npm/error-stack-parser)
|
|---|
| 11 |
|
|---|
| 12 | Simple, cross-browser [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) parser.
|
|---|
| 13 | This library parses and extracts function names, URLs, line numbers, and column numbers from the given Error's `stack` as
|
|---|
| 14 | an Array of [StackFrame](http://git.io/stackframe)s.
|
|---|
| 15 |
|
|---|
| 16 | Once you have parsed out StackFrames, you can do much more interesting things. See [stacktrace-gps](http://git.io/stacktrace-gps).
|
|---|
| 17 |
|
|---|
| 18 | Note that in IE9 and earlier, `Error` objects don't have enough information to extract much of anything. In IE 10, `Error`s
|
|---|
| 19 | are given a `stack` once they're `throw`n.
|
|---|
| 20 |
|
|---|
| 21 | ## Browser Support
|
|---|
| 22 | [](https://saucelabs.com/u/stacktracejs)
|
|---|
| 23 |
|
|---|
| 24 | ## Usage
|
|---|
| 25 | ```js
|
|---|
| 26 | ErrorStackParser.parse(new Error('BOOM'));
|
|---|
| 27 |
|
|---|
| 28 | => [
|
|---|
| 29 | StackFrame({functionName: 'foo', args: [], fileName: 'path/to/file.js', lineNumber: 35, columnNumber: 79, isNative: false, isEval: false}),
|
|---|
| 30 | StackFrame({functionName: 'Bar', fileName: 'https://cdn.somewherefast.com/utils.min.js', lineNumber: 1, columnNumber: 832, isNative: false, isEval: false, isConstructor: true}),
|
|---|
| 31 | StackFrame(... and so on ...)
|
|---|
| 32 | ]
|
|---|
| 33 | ```
|
|---|
| 34 |
|
|---|
| 35 | ## Installation
|
|---|
| 36 | ```bash
|
|---|
| 37 | npm install error-stack-parser
|
|---|
| 38 | bower install error-stack-parser
|
|---|
| 39 | https://raw.githubusercontent.com/stacktracejs/error-stack-parser/master/dist/error-stack-parser.min.js
|
|---|
| 40 | ```
|
|---|
| 41 |
|
|---|
| 42 | ## Contributing
|
|---|
| 43 | Want to be listed as a *Contributor*? Start with the [Contributing Guide](.github/CONTRIBUTING.md)!
|
|---|
| 44 |
|
|---|