GeezerVison is showing github.com — repl: fix error message printing · nodejs/node@8d4936d
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/repl.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -610,7 +610,7 @@ function REPLServer(prompt, |
610 | 610 | errStack = self.writer(e); |
611 | 611 |
|
612 | 612 | // Remove one line error braces to keep the old style in place. |
613 | | - if (errStack[errStack.length - 1] === ']') { |
| 613 | + if (errStack[0] === '[' && errStack[errStack.length - 1] === ']') { |
614 | 614 | errStack = errStack.slice(1, -1); |
615 | 615 | } |
616 | 616 | } |
|
Collapse file
Copy file name to clipboard +23Lines changed: 23 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +'use strict'; |
| 2 | +require('../common'); |
| 3 | +const { PassThrough } = require('stream'); |
| 4 | +const assert = require('assert'); |
| 5 | +const repl = require('repl'); |
| 6 | + |
| 7 | +{ |
| 8 | + const input = new PassThrough(); |
| 9 | + const output = new PassThrough(); |
| 10 | + |
| 11 | + const r = repl.start({ |
| 12 | + prompt: '', |
| 13 | + input, |
| 14 | + output, |
| 15 | + writer: String, |
| 16 | + terminal: false, |
| 17 | + useColors: false |
| 18 | + }); |
| 19 | + |
| 20 | + r.write('throw new Error("foo[a]")\n'); |
| 21 | + r.close(); |
| 22 | + assert.strictEqual(output.read().toString(), 'Uncaught Error: foo[a]\n'); |
| 23 | +} |