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

498 B

importance: 5


Inherit from SyntaxError

Create a class FormatError that inherits from the built-in SyntaxError class.

It should support message, name and stack properties.

Usage example:

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

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

alert( err instanceof FormatError ); // true
alert( err instanceof SyntaxError ); // true (because inherits from SyntaxError)