Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1d24701
Update stackframe dependency.
ssenbud Sep 21, 2015
b058de2
Merge branch 'master' of github.com:stacktracejs/error-stack-parser
oliversalzburg Oct 15, 2015
ce53af0
Full semver for bower dependency
oliversalzburg Oct 15, 2015
883bce1
Bower cleanup
oliversalzburg Oct 15, 2015
46e2f7c
Enable Sauce for all supported browsers
ssenbud Nov 16, 2015
ec2f79d
Avoid premature/lossy normalization of function names in IE/Chrome. F…
ssenbud Nov 16, 2015
6d1b89b
Specify Windows for Firefox tests in the hopes it'll work reliably on…
ssenbud Nov 17, 2015
e1bb634
Remove Firefox beta from Sauce testing because it keeps failing due t…
ssenbud Nov 22, 2015
1d90870
Deduplicate browser support sections
ssenbud Nov 28, 2015
d6dc380
Exclude eval information when parsing Chrome stacks. Fixes #25
ssenbud Nov 29, 2015
53dd6f8
Improve handling of eval() stack frames.
ssenbud Nov 29, 2015
7bcdfd1
Switch to Jasmine 2 for testing.
ssenbud Nov 29, 2015
785d79b
Remove IE7 from CI - too unreliable.
ssenbud Dec 2, 2015
f5c0c80
Allow stacktraces with no location information in Safari. Should fix …
ssenbud Dec 2, 2015
3e56eae
Release 1.3.2
ssenbud Dec 16, 2015
bc9d544
Remove .nvmrc
ssenbud Jan 2, 2016
55e682b
Add test task for PRs
ssenbud Jan 2, 2016
0e572cc
Don't use Sauce for PRs, use local browsers.
ssenbud Jan 2, 2016
b6d8241
Replace use of Array.map and Array.filter in order to avoid the need …
ssenbud Jan 2, 2016
b783149
Fully parse function names with @ in Error.stack
leonidborisenko Jan 3, 2016
e3eae6a
Merge pull request #27 from leonidborisenko/fully-parse-fn-name-with-…
eriwen Jan 3, 2016
5f850c9
Update stackframe to 1.x.x
btd Jan 5, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.pid
*.gz

bower_components
node_modules
build
coverage
Expand Down
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"es3": true,
"camelcase": true,
"nonbsp": true,
"maxlen": 130,
"predef": {
"afterEach": false,
"beforeEach": false,
Expand Down
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

21 changes: 11 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
language: node_js
node_js:
- '0.12'
script: gulp ci
install:
- npm install
- npm install bower -g
sudo: false
node_js: stable
addons:
sauce_connect: true
env:
global:
- secure: hNvLoSVYWY+O2Oz5usb5+IFUMgWdM21xxZuCR4+qh1yJhlQYTaFANBDYJ5vhC74DbzLHRmy8ZUYa1G/4R4w8KXX9cCt6PFD2ETPpmZPJROHzoAoaYKahOAqdcMSVHn0BVKZCeAvPeLoBhvIfMJx4DOcRTTkKPzTJzg4ewzR/v3g=
- secure: hnc8EGbHzAlz6lAfVoGSf47pecv7G/LxbDHCIN2jn23SgU9SdScY9LT9K0X69smFsdBmOSCWDRRqPgX859sS/tz3lGHW6lCRn3mqclCNVhFNM6Vd+dB4hwAEvJQXhtMAaxM5Bqop+8C8OQ4NdoHgSYcdEvMT0CaWU1ZFrpjiBs4=
firefox: latest
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
before_script:
- npm install
script:
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then gulp ci; else gulp pr; fi
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
## v1.1.2
## v1.3.2
* Handle Safari stack entries with no location information

## v1.3.0
* Significantly improved handling of eval()
* Add many browsers to CI

## v1.2.2
* Handle native functions in V8 stack traces

## v1.2.0
Expand Down
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ an Array of [StackFrame](http://git.io/stackframe)s.
Once you have parsed out StackFrames, you can do much more interesting things. See [stacktrace-gps](http://git.io/stacktrace-gps).

Note that in IE9 and earlier, `Error` objects don't have enough information to extract much of anything. In IE 10, `Error`s
are given a `stack` once they're `throw`n.
are given a `stack` once they're `throw`n.

## Browser Support
[![Sauce Test Status](https://saucelabs.com/browser-matrix/stacktracejs.svg)](https://saucelabs.com/u/stacktracejs)

## Usage
```js
Expand All @@ -29,15 +32,6 @@ bower install error-stack-parser
https://raw.githubusercontent.com/stacktracejs/error-stack-parser/master/dist/error-stack-parser.min.js
```

## Browser Support
* Chrome 1+
* Firefox 3.6+
* Safari 7+
* Opera 9+
* IE 10+
* iOS 7+
* Android 4.2+

## Contributing
Want to be listed as a *Contributor*? Start with the [Contributing Guide](CONTRIBUTING.md)!

Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "error-stack-parser",
"main": "./error-stack-parser.js",
"main": "./dist/error-stack-parser.js",
"homepage": "https://github.com/stacktracejs/error-stack-parser",
"authors": [
"Eric Wendelin <[email protected]> (http://www.eriwen.com)",
"Victor Homyakov <[email protected]> (https://github.com/victor-homyakov)"
],
"description": "Extract meaning from JS Errors",
"dependencies": {
"stackframe": "~0"
"stackframe": "~0.3.1"
},
"moduleType": [
"amd",
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "error-stack-parser",
"repository": "stacktracejs/error-stack-parser",
"description": "Extract meaning from JS Errors",
"version": "1.2.2",
"version": "1.3.3",
"keywords": [
"stacktrace",
"error",
Expand Down
2 changes: 0 additions & 2 deletions dist/error-stack-parser-with-polyfills.min.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/error-stack-parser-with-polyfills.min.js.map

This file was deleted.

81 changes: 65 additions & 16 deletions dist/error-stack-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,34 @@
'use strict';

var FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+\:\d+/;
var CHROME_IE_STACK_REGEXP = /\s+at .*(\S+\:\d+|\(native\))/;
var CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+\:\d+|\(native\))/m;
var SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code\])?$/;

function _map(array, fn, thisArg) {
if (typeof Array.prototype.map === 'function') {
return array.map(fn, thisArg);
} else {
var output = new Array(array.length);
for (var i = 0; i < array.length; i++) {
output[i] = fn.call(thisArg, array[i]);
}
return output;
}
}

function _filter(array, fn, thisArg) {
if (typeof Array.prototype.filter === 'function') {
return array.filter(fn, thisArg);
} else {
var output = [];
for (var i = 0; i < array.length; i++) {
if (fn.call(thisArg, array[i])) {
output.push(array[i]);
}
}
return output;
}
}

return {
/**
Expand All @@ -27,7 +54,7 @@
return this.parseOpera(error);
} else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {
return this.parseV8OrIE(error);
} else if (error.stack && error.stack.match(FIREFOX_SAFARI_STACK_REGEXP)) {
} else if (error.stack) {
return this.parseFFOrSafari(error);
} else {
throw new Error('Cannot parse given Error object');
Expand Down Expand Up @@ -57,24 +84,44 @@
},

parseV8OrIE: function ErrorStackParser$$parseV8OrIE(error) {
return error.stack.split('\n').filter(function (line) {
var filtered = _filter(error.stack.split('\n'), function (line) {
return !!line.match(CHROME_IE_STACK_REGEXP);
}, this).map(function (line) {
var tokens = line.replace(/^\s+/, '').split(/\s+/).slice(1);
}, this);

return _map(filtered, function (line) {
if (line.indexOf('(eval ') > -1) {
// Throw away eval information until we implement stacktrace.js/stackframe#8
line = line.replace(/eval code/g, 'eval').replace(/(\(eval at [^\()]*)|(\)\,.*$)/g, '');
}
var tokens = line.replace(/^\s+/, '').replace(/\(eval code/g, '(').split(/\s+/).slice(1);
var locationParts = this.extractLocation(tokens.pop());
var functionName = (!tokens[0] || tokens[0] === 'Anonymous') ? undefined : tokens[0];
return new StackFrame(functionName, undefined, locationParts[0], locationParts[1], locationParts[2], line);
var functionName = tokens.join(' ') || undefined;
var fileName = locationParts[0] === 'eval' ? undefined : locationParts[0];

return new StackFrame(functionName, undefined, fileName, locationParts[1], locationParts[2], line);
}, this);
},

parseFFOrSafari: function ErrorStackParser$$parseFFOrSafari(error) {
return error.stack.split('\n').filter(function (line) {
return !!line.match(FIREFOX_SAFARI_STACK_REGEXP);
}, this).map(function (line) {
var tokens = line.split('@');
var locationParts = this.extractLocation(tokens.pop());
var functionName = tokens.shift() || undefined;
return new StackFrame(functionName, undefined, locationParts[0], locationParts[1], locationParts[2], line);
var filtered = _filter(error.stack.split('\n'), function (line) {
return !line.match(SAFARI_NATIVE_CODE_REGEXP);
}, this);

return _map(filtered, function (line) {
// Throw away eval information until we implement stacktrace.js/stackframe#8
if (line.indexOf(' > eval') > -1) {
line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval\:\d+\:\d+/g, ':$1');
}

if (line.indexOf('@') === -1 && line.indexOf(':') === -1) {
// Safari eval frames only have function names and nothing else
return new StackFrame(line);
} else {
var tokens = line.split('@');
var locationParts = this.extractLocation(tokens.pop());
var functionName = tokens.shift() || undefined;
return new StackFrame(functionName, undefined, locationParts[0], locationParts[1], locationParts[2], line);
}
}, this);
},

Expand Down Expand Up @@ -121,10 +168,12 @@

// Opera 10.65+ Error.stack very similar to FF/Safari
parseOpera11: function ErrorStackParser$$parseOpera11(error) {
return error.stack.split('\n').filter(function (line) {
var filtered = _filter(error.stack.split('\n'), function (line) {
return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) &&
!line.match(/^Error created at/);
}, this).map(function (line) {
}, this);

return _map(filtered, function (line) {
var tokens = line.split('@');
var locationParts = this.extractLocation(tokens.pop());
var functionCall = (tokens.shift() || '');
Expand Down
Loading