From bbffd9e5025ef22156c7d21c746a51529f821664 Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 26 Apr 2011 09:48:28 -0700 Subject: [PATCH] Close #983 Better JSON.parse error detection Previous pattern would only catch ILLEGAL, not { or other known-but-unexpected JSON tokens. --- lib/repl.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/repl.js b/lib/repl.js index 33794776727..ffe2b77e469 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -184,8 +184,8 @@ function REPLServer(prompt, stream) { // It could also be an error from JSON.parse } else if (e && e.stack && - e.stack.match('Unexpected token ILLEGAL') && - e.stack.match(/Object.parse \(native\)/)) { + e.stack.match(/^SyntaxError: Unexpected token .*\n/) && + e.stack.match(/\n at Object.parse \(native\)\n/)) { throw e; } }