google / google/closure-compiler

DOMException should be subclass of Error

Open
#1,854 0 comments 0 reactions 0 assignees View on GitHub
Externs
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Per http://heycam.github.io/webidl/#es-exception-objects and http://heycam.github.io/webidl/#es-DOMException-prototype-object DOMException should be a subclass of Error and therefore have `name` and `message` properties.

Sample:

``` js
/** @param {DOMException} error */
function showError(error) {
console.log(error.name);
console.log(error.message);
}
```

Closure Compiler service reports:

```
JSC_INEXISTENT_PROPERTY: Property name never defined on DOMException at line 3 character 20
console.log(error.name);
^
JSC_INEXISTENT_PROPERTY: Property message never defined on DOMException at line 4 character 20
console.log(error.message);
^
```

Also note that `code` is intended to be an own-property not necessarily a getter on the prototype, but this is not clearly specified at the moment, and browsers (e.g. Chrome) may implement it as an inherited getter.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.