Add stack trace in engines based on V8. Fixes #331

redux
Marco Baumgartl 9 years ago
parent eaca5f0acf
commit 940a66fb38

@ -778,8 +778,11 @@ function generateJavascript(ast, options) {
' this.expected = expected;',
' this.found = found;',
' this.location = location;',
'',
' this.name = "SyntaxError";',
'',
' if (typeof Error.captureStackTrace === "function") {',
' Error.captureStackTrace(this, peg$SyntaxError);',
' }',
' }',
'',
' peg$subclass(peg$SyntaxError, Error);',

@ -5,6 +5,10 @@ function GrammarError(message, location) {
this.name = "GrammarError";
this.message = message;
this.location = location;
if (typeof Error.captureStackTrace === "function") {
Error.captureStackTrace(this, GrammarError);
}
}
classes.subclass(GrammarError, Error);

@ -16,8 +16,11 @@ module.exports = (function() {
this.expected = expected;
this.found = found;
this.location = location;
this.name = "SyntaxError";
if (typeof Error.captureStackTrace === "function") {
Error.captureStackTrace(this, peg$SyntaxError);
}
}
peg$subclass(peg$SyntaxError, Error);

Loading…
Cancel
Save