Previous pattern would only catch ILLEGAL, not { or other
known-but-unexpected JSON tokens.
// 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;
}
}