Skip to content

Commit

Permalink
Merge pull request #17 from kjg/optional_column_number
Browse files Browse the repository at this point in the history
Don't expect column number to always exists
  • Loading branch information
felixge authored May 15, 2017
2 parents 4a28231 + 1ec9ba4 commit 962ed6a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/stack-trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ exports.parse = function(err) {
});
}

var lineMatch = line.match(/at (?:(.+)\s+\()?(?:(.+?):(\d+):(\d+)|([^)]+))\)?/);
var lineMatch = line.match(/at (?:(.+)\s+\()?(?:(.+?):(\d+)(?::(\d+))?|([^)]+))\)?/);
if (!lineMatch) {
return;
}
Expand Down
13 changes: 13 additions & 0 deletions test/integration/test-parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ var stackTrace = require(common.dir.lib + '/stack-trace');
assert.equal(trace.length, 2);
})();

(function testTraceWitoutColumnNumbers() {
var err = {};
err.stack =
'AssertionError: true == false\n' +
' at Test.fn (/Users/felix/code/node-fast-or-slow/test/fast/example/test-example.js:6)\n' +
' at Test.run (/Users/felix/code/node-fast-or-slow/lib/test.js:45)';

var trace = stackTrace.parse(err);
assert.strictEqual(trace[0].getFileName(), "/Users/felix/code/node-fast-or-slow/test/fast/example/test-example.js");
assert.strictEqual(trace[0].getLineNumber(), 6);
assert.strictEqual(trace[0].getColumnNumber(), null);
})();

(function testCompareRealWithParsedStackTrace() {
var realTrace, err;
function TestClass() {
Expand Down

0 comments on commit 962ed6a

Please sign in to comment.