From: isaacs Date: Tue, 26 Apr 2011 16:48:28 +0000 (-0700) Subject: Close #983 Better JSON.parse error detection X-Git-Tag: v0.4.8~40 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bbffd9e5025ef22156c7d21c746a51529f821664;p=platform%2Fupstream%2Fnodejs.git Close #983 Better JSON.parse error detection Previous pattern would only catch ILLEGAL, not { or other known-but-unexpected JSON tokens. --- diff --git a/lib/repl.js b/lib/repl.js index 3379477..ffe2b77 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; } }