Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix error with anonymous, local functions. Bump version and announce …

…compat with node 0.4.X
  • Loading branch information...
commit 63e02b12b0e73b45e6be7f74784561523285b7ac 1 parent 0e021f5
@chrisdickinson authored
Showing with 17 additions and 8 deletions.
  1. +2 −2 package.json
  2. +15 −6 trace.js
View
4 package.json
@@ -2,7 +2,7 @@
"author": "Chris Dickinson <chris@neversaw.us> (http://neversaw.us/)",
"name": "tracejs",
"description": "Expand Error.stack traces into usable objects providing context and highlighting",
- "version": "0.0.1",
+ "version": "0.0.2",
"homepage": "http://github.com/chrisdickinson/tracejs/",
"repository": {
"type": "git",
@@ -10,7 +10,7 @@
},
"main": "trace.js",
"engines": {
- "node": "~v0.4.7"
+ "node": "0.4.X"
},
"dependencies": {"ansi-color":"0.2.X"},
"devDependencies": {}
View
21 trace.js
@@ -2,7 +2,8 @@ var fs = require('fs'),
natives = process.binding('natives'),
color = require('ansi-color').set;
-var err_re = / at ([^\s]+) \(([\w\d\._\-\/]+):(\d+):(\d+)\)/g;
+var err_re1 = / at ([^\s]+) \(([\w\d\._\-\/]+):(\d+):(\d+)\)/g,
+ err_re2 = / at ([^:]+):(\d+):(\d+)/g;
var Trace = function(first_line, frames, original_error) {
this.first_line = first_line;
@@ -115,16 +116,24 @@ var trace = function(err) {
stack = lines.slice(1).join('\n');
var frames = [],
- match;
+ match1, match2;
do {
- match = err_re(stack);
- if(match) {
+ match1 = err_re1(stack);
+ match2 = err_re2(stack);
+
+ if(match1) {
+ frames.push(
+ new Frame(match1[1], match1[2], parseInt(match1[3], 10), parseInt(match1[4], 10))
+ );
+ stack = stack.slice(match1.index + match1[0].length);
+ } else if(match2) {
frames.push(
- new Frame(match[1], match[2], parseInt(match[3], 10), parseInt(match[4], 10))
+ new Frame('<anonymous>', match2[1], parseInt(match2[2], 10), parseInt(match2[3], 10))
);
+ stack = stack.slice(match2.index + match2[0].length);
}
- } while(match);
+ } while(stack.length);
return new Trace(first, frames, err);
};
Please sign in to comment.
Something went wrong with that request. Please try again.