@ -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.name = "SyntaxError";
Error.captureStackTrace(this, peg$SyntaxError);
peg$subclass(peg$SyntaxError, Error);