Add stack trace in engines based on V8. Fixes #331
This commit is contained in:
parent
eaca5f0acf
commit
940a66fb38
|
@ -778,8 +778,11 @@ function generateJavascript(ast, options) {
|
||||||
' this.expected = expected;',
|
' this.expected = expected;',
|
||||||
' this.found = found;',
|
' this.found = found;',
|
||||||
' this.location = location;',
|
' this.location = location;',
|
||||||
'',
|
|
||||||
' this.name = "SyntaxError";',
|
' this.name = "SyntaxError";',
|
||||||
|
'',
|
||||||
|
' if (typeof Error.captureStackTrace === "function") {',
|
||||||
|
' Error.captureStackTrace(this, peg$SyntaxError);',
|
||||||
|
' }',
|
||||||
' }',
|
' }',
|
||||||
'',
|
'',
|
||||||
' peg$subclass(peg$SyntaxError, Error);',
|
' peg$subclass(peg$SyntaxError, Error);',
|
||||||
|
|
|
@ -5,6 +5,10 @@ function GrammarError(message, location) {
|
||||||
this.name = "GrammarError";
|
this.name = "GrammarError";
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
|
|
||||||
|
if (typeof Error.captureStackTrace === "function") {
|
||||||
|
Error.captureStackTrace(this, GrammarError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
classes.subclass(GrammarError, Error);
|
classes.subclass(GrammarError, Error);
|
||||||
|
|
|
@ -16,8 +16,11 @@ module.exports = (function() {
|
||||||
this.expected = expected;
|
this.expected = expected;
|
||||||
this.found = found;
|
this.found = found;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
|
|
||||||
this.name = "SyntaxError";
|
this.name = "SyntaxError";
|
||||||
|
|
||||||
|
if (typeof Error.captureStackTrace === "function") {
|
||||||
|
Error.captureStackTrace(this, peg$SyntaxError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
peg$subclass(peg$SyntaxError, Error);
|
peg$subclass(peg$SyntaxError, Error);
|
||||||
|
|
Loading…
Reference in a new issue