| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent acd4924 commit 6642f54
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1740,6 +1740,7 @@ void AppendExceptionLine(Environment* env, | |||
| 1740 | 1740 | } | |
| 1741 | 1741 | ||
| 1742 | 1742 | // Print (filename):(line number): (message). | |
| 1743 | + ScriptOrigin origin = message->GetScriptOrigin(); | ||
| 1743 | 1744 | node::Utf8Value filename(env->isolate(), message->GetScriptResourceName()); | |
| 1744 | 1745 | const char* filename_string = *filename; | |
| 1745 | 1746 | int linenum = message->GetLineNumber(); | |
@@ -1768,8 +1769,16 @@ void AppendExceptionLine(Environment* env, | |||
| 1768 | 1769 | // sourceline to 78 characters, and we end up not providing very much | |
| 1769 | 1770 | // useful debugging info to the user if we remove 62 characters. | |
| 1770 | 1771 | ||
| 1772 | + int script_start = | ||
| 1773 | + (linenum - origin.ResourceLineOffset()->Value()) == 1 ? | ||
| 1774 | + origin.ResourceColumnOffset()->Value() : 0; | ||
| 1771 | 1775 | int start = message->GetStartColumn(env->context()).FromMaybe(0); | |
| 1772 | 1776 | int end = message->GetEndColumn(env->context()).FromMaybe(0); | |
| 1777 | + if (start >= script_start) { | ||
| 1778 | + CHECK_GE(end, start); | ||
| 1779 | + start -= script_start; | ||
| 1780 | + end -= script_start; | ||
| 1781 | + } | ||
| 1773 | 1782 | ||
| 1774 | 1783 | char arrow[1024]; | |
| 1775 | 1784 | int max_off = sizeof(arrow) - 2; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -93,13 +93,14 @@ assert.strictEqual(script.runInContext(ctx), false); | |||
| 93 | 93 | // Error on the first line of a module should | |
| 94 | 94 | // have the correct line and column number | |
| 95 | 95 | assert.throws(() => { | |
| 96 | - vm.runInContext('throw new Error()', context, { | ||
| 96 | + vm.runInContext(' throw new Error()', context, { | ||
| 97 | 97 | filename: 'expected-filename.js', | |
| 98 | 98 | lineOffset: 32, | |
| 99 | 99 | columnOffset: 123 | |
| 100 | 100 | }); | |
| 101 | 101 | }, (err) => { | |
| 102 | - return /expected-filename\.js:33:130/.test(err.stack); | ||
| 102 | + return /^ \^/m.test(err.stack) && | ||
| 103 | + /expected-filename\.js:33:131/.test(err.stack); | ||
| 103 | 104 | }, 'Expected appearance of proper offset in Error stack'); | |
| 104 | 105 | ||
| 105 | 106 | // https://github.com/nodejs/node/issues/6158 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments