| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent eaec35d commit 931addb
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1585,6 +1585,7 @@ void AppendExceptionLine(Environment* env, | |||
| 1585 | 1585 | } | |
| 1586 | 1586 | ||
| 1587 | 1587 | // Print (filename):(line number): (message). | |
| 1588 | + ScriptOrigin origin = message->GetScriptOrigin(); | ||
| 1588 | 1589 | node::Utf8Value filename(env->isolate(), message->GetScriptResourceName()); | |
| 1589 | 1590 | const char* filename_string = *filename; | |
| 1590 | 1591 | int linenum = message->GetLineNumber(); | |
@@ -1613,8 +1614,16 @@ void AppendExceptionLine(Environment* env, | |||
| 1613 | 1614 | // sourceline to 78 characters, and we end up not providing very much | |
| 1614 | 1615 | // useful debugging info to the user if we remove 62 characters. | |
| 1615 | 1616 | ||
| 1617 | + int script_start = | ||
| 1618 | + (linenum - origin.ResourceLineOffset()->Value()) == 1 ? | ||
| 1619 | + origin.ResourceColumnOffset()->Value() : 0; | ||
| 1616 | 1620 | int start = message->GetStartColumn(env->context()).FromMaybe(0); | |
| 1617 | 1621 | int end = message->GetEndColumn(env->context()).FromMaybe(0); | |
| 1622 | + if (start >= script_start) { | ||
| 1623 | + CHECK_GE(end, start); | ||
| 1624 | + start -= script_start; | ||
| 1625 | + end -= script_start; | ||
| 1626 | + } | ||
| 1618 | 1627 | ||
| 1619 | 1628 | char arrow[1024]; | |
| 1620 | 1629 | int max_off = sizeof(arrow) - 2; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -72,13 +72,14 @@ assert.strictEqual(script.runInContext(ctx), false); | |||
| 72 | 72 | // Error on the first line of a module should | |
| 73 | 73 | // have the correct line and column number | |
| 74 | 74 | assert.throws(() => { | |
| 75 | - vm.runInContext('throw new Error()', context, { | ||
| 75 | + vm.runInContext(' throw new Error()', context, { | ||
| 76 | 76 | filename: 'expected-filename.js', | |
| 77 | 77 | lineOffset: 32, | |
| 78 | 78 | columnOffset: 123 | |
| 79 | 79 | }); | |
| 80 | 80 | }, (err) => { | |
| 81 | - return /expected-filename\.js:33:130/.test(err.stack); | ||
| 81 | + return /^ \^/m.test(err.stack) && | ||
| 82 | + /expected-filename\.js:33:131/.test(err.stack); | ||
| 82 | 83 | }, 'Expected appearance of proper offset in Error stack'); | |
| 83 | 84 | ||
| 84 | 85 | // https://github.com/nodejs/node/issues/6158 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments