SyntaxError.js 438 B

12345678910111213141516
  1. export class SyntaxError extends Error {
  2. static createError (msg, token) {
  3. const val = SyntaxError.getErrorString(msg, token);
  4. return new SyntaxError(val);
  5. }
  6. static getErrorString (symbol, token) {
  7. return `Syntax error: Expecting '${symbol}' but found '${token.text}' at line:${token.line}, column:${token.column}`;
  8. }
  9. constructor (...msg) {
  10. super(...msg);
  11. Error.captureStackTrace(this, SyntaxError);
  12. }
  13. }