Close #983 Better JSON.parse error detection
authorisaacs <i@izs.me>
Tue, 26 Apr 2011 16:48:28 +0000 (09:48 -0700)
committerisaacs <i@izs.me>
Tue, 26 Apr 2011 16:48:28 +0000 (09:48 -0700)
Previous pattern would only catch ILLEGAL, not { or other
known-but-unexpected JSON tokens.

lib/repl.js

index 3379477..ffe2b77 100644 (file)
@@ -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;
           }
         }