FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Custom errors, extending Error by ockley · Pull Request #275 · javascript-tutorial/da.javascript.info · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .md  (4) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
        • solution.md
        • task.md
      • article.md
    • index.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ class FormatError extends SyntaxError {
}
}

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

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

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ importance: 5

---

# Inherit from SyntaxError
# Nedarv fra SyntaxError

Create a class `FormatError` that inherits from the built-in `SyntaxError` class.
Opret en klasse `FormatError` som nedarver fra den indbyggede `SyntaxError`-klasse.

It should support `message`, `name` and `stack` properties.
Den bør understøtte `message`, `name` og `stack` egenskaber.

Usage example:
Brugseksempel:

```js
let err = new FormatError("formatting error");
let err = new FormatError("formatteringsfejl");

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

alert( err instanceof FormatError ); // true
alert( err instanceof SyntaxError ); // true (because inherits from SyntaxError)
alert( err instanceof SyntaxError ); // true (fordi den nedarver fra SyntaxError)
```
Loading

Back | FazBrowse Home | New Git URL