Permalink
Browse files

Close #983 Better JSON.parse error detection

Previous pattern would only catch ILLEGAL, not { or other
known-but-unexpected JSON tokens.
  • Loading branch information...
1 parent 68c8a69 commit bbffd9e5025ef22156c7d21c746a51529f821664 @isaacs isaacs committed Apr 26, 2011
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/repl.js
View
@@ -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;
}
}

0 comments on commit bbffd9e

Please sign in to comment.