up
This commit is contained in:
parent
7ed245d540
commit
799a7e220a
11 changed files with 410 additions and 37 deletions
|
@ -4,9 +4,12 @@ importance: 5
|
|||
|
||||
# Inherit from SyntaxError
|
||||
|
||||
Create an error `FormatError` that inherits from `SyntaxError`.
|
||||
Create a class `FormatError` that inherits from the built-in `SyntaxError` class.
|
||||
|
||||
It should support `message`, `name` and `stack` properties.
|
||||
|
||||
Usage example:
|
||||
|
||||
```js
|
||||
let err = new FormatError("formatting error");
|
||||
|
||||
|
@ -14,5 +17,6 @@ alert( err.message ); // formatting error
|
|||
alert( err.name ); // FormatError
|
||||
alert( err.stack ); // stack
|
||||
|
||||
alert( err instanceof SyntaxError ); // true
|
||||
alert( err instanceof FormatError ); // true
|
||||
alert( err instanceof SyntaxError ); // true (because inherits from SyntaxError)
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue