Skip to content

Commit

Permalink
Retain context information.
Browse files Browse the repository at this point in the history
  • Loading branch information
lgrammel committed Oct 5, 2015
1 parent 9181061 commit 1f5f461
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/restore-stacktrace.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ function restoreStacktrace(options) {
var result = '';

lines.forEach(function(stackLine) {
stackLine = stackLine.trim();

if (stackLine.trim().indexOf('at ') === 0) {
if (stackLine.indexOf('at ') === 0) {

var sourceUrl = stackLine.trim().match(/^at http(s?):\/\//) ?
// 1) at http://something/bundle.js:1:1
// isOnlyUrl
// true: " at http://something/bundle.js:1:1"
// false: " at bla.bla (http://something/bundle.js:1:1)"
var isOnlyUrl = stackLine.match(/^at http(s?):\/\//);

var sourceUrl = isOnlyUrl ?
stackLine.substring('at '.length) :
// 2) at bla.bla (http://something/bundle.js:1:1)
stackLine.substring(
stackLine.lastIndexOf('(') + 1,
stackLine.lastIndexOf(')')
Expand Down Expand Up @@ -65,6 +69,9 @@ function restoreStacktrace(options) {
}

result += ' at ';
if (!isOnlyUrl) {
result += stackLine.substring('at '.length, stackLine.lastIndexOf('('));
}
result += originalPosition.name;
result += ' (' + source + ':' + originalPosition.line + ':' + originalPosition.column + ')';
} else {
Expand Down

0 comments on commit 1f5f461

Please sign in to comment.