2021-01-11 12:13:41 -05:00
|
|
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
2020-04-11 11:42:02 -04:00
|
|
|
|
2021-01-09 01:27:46 -05:00
|
|
|
((window) => {
|
|
|
|
const nameToCodeMapping = Object.create(
|
|
|
|
null,
|
|
|
|
{
|
|
|
|
IndexSizeError: { value: 1 },
|
|
|
|
HierarchyRequestError: { value: 3 },
|
|
|
|
WrongDocumentError: { value: 4 },
|
|
|
|
InvalidCharacterError: { value: 5 },
|
|
|
|
NoModificationAllowedError: { value: 7 },
|
|
|
|
NotFoundError: { value: 8 },
|
|
|
|
NotSupportedError: { value: 9 },
|
|
|
|
InvalidStateError: { value: 11 },
|
|
|
|
SyntaxError: { value: 12 },
|
|
|
|
InvalidModificationError: { value: 13 },
|
|
|
|
NamespaceError: { value: 14 },
|
|
|
|
InvalidAccessError: { value: 15 },
|
|
|
|
TypeMismatchError: { value: 17 },
|
|
|
|
SecurityError: { value: 18 },
|
|
|
|
NetworkError: { value: 19 },
|
|
|
|
AbortError: { value: 20 },
|
|
|
|
URLMismatchError: { value: 21 },
|
|
|
|
QuotaExceededError: { value: 22 },
|
|
|
|
TimeoutError: { value: 23 },
|
|
|
|
InvalidNodeTypeError: { value: 24 },
|
|
|
|
DataCloneError: { value: 25 },
|
|
|
|
},
|
|
|
|
);
|
|
|
|
class DOMException extends Error {
|
|
|
|
#name = "";
|
|
|
|
#code = 0;
|
2020-04-11 11:42:02 -04:00
|
|
|
|
2021-01-09 01:27:46 -05:00
|
|
|
constructor(message = "", name = "Error") {
|
|
|
|
super(message);
|
|
|
|
this.#name = name;
|
|
|
|
this.#code = nameToCodeMapping[name] ?? 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
get name() {
|
|
|
|
return this.#name;
|
|
|
|
}
|
2020-04-11 11:42:02 -04:00
|
|
|
|
2021-01-09 01:27:46 -05:00
|
|
|
get code() {
|
|
|
|
return this.#code;
|
|
|
|
}
|
2020-04-11 11:42:02 -04:00
|
|
|
}
|
2021-01-09 01:27:46 -05:00
|
|
|
|
|
|
|
window.DOMException = DOMException;
|
|
|
|
})(this);
|