en.javascript.info/1-js/10-error-handling/2-custom-errors/1-format-error/solution.md
2019-03-05 18:44:28 +03:00

346 B

class FormatError extends SyntaxError {
  constructor(message) {
    super(message);
    this.name = "FormatError";
  }
}

let err = new FormatError("formatting error");

alert( err.message ); // formatting error
alert( err.name ); // FormatError
alert( err.stack ); // stack

alert( err instanceof SyntaxError ); // true