Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

@@ -0,0 +1,41 @@
"use strict";
const addConstants = require("../utils").addConstants;
const table = require("./dom-exception-table.json"); // https://heycam.github.io/webidl/#idl-DOMException-error-names
// Precompute some stuff. Mostly unnecessary once we take care of the TODO below.
const namesWithCodes = Object.keys(table).filter(name => "legacyCodeValue" in table[name]);
const codesToNames = Object.create(null);
for (const name of namesWithCodes) {
codesToNames[table[name].legacyCodeValue] = name;
}
module.exports = DOMException;
// TODO: update constructor signature to match WebIDL spec
// See also https://github.com/heycam/webidl/pull/22 which isn't merged as of yet
function DOMException(code, message) {
const name = codesToNames[code];
if (message === undefined) {
message = table[name].description;
}
Error.call(this, message);
Object.defineProperty(this, "name", { value: name, writable: true, configurable: true, enumerable: false });
Object.defineProperty(this, "code", { value: code, writable: true, configurable: true, enumerable: false });
if (Error.captureStackTrace) {
Error.captureStackTrace(this, DOMException);
}
}
Object.setPrototypeOf(DOMException, Error);
Object.setPrototypeOf(DOMException.prototype, Error.prototype);
const constants = Object.create(null);
for (const name of namesWithCodes) {
constants[table[name].legacyCodeName] = table[name].legacyCodeValue;
}
addConstants(DOMException, constants);

View File

@@ -0,0 +1,134 @@
{
"IndexSizeError": {
"description": "The index is not in the allowed range.",
"legacyCodeName": "INDEX_SIZE_ERR",
"legacyCodeValue": 1
},
"HierarchyRequestError": {
"description": "The operation would yield an incorrect node tree.",
"legacyCodeName": "HIERARCHY_REQUEST_ERR",
"legacyCodeValue": 3
},
"WrongDocumentError": {
"description": "The object is in the wrong document.",
"legacyCodeName": "WRONG_DOCUMENT_ERR",
"legacyCodeValue": 4
},
"InvalidCharacterError": {
"description": "The string contains invalid characters.",
"legacyCodeName": "INVALID_CHARACTER_ERR",
"legacyCodeValue": 5
},
"NoModificationAllowedError": {
"description": "The object can not be modified.",
"legacyCodeName": "NO_MODIFICATION_ALLOWED_ERR",
"legacyCodeValue": 7
},
"NotFoundError": {
"description": "The object can not be found here.",
"legacyCodeName": "NOT_FOUND_ERR",
"legacyCodeValue": 8
},
"NotSupportedError": {
"description": "The operation is not supported.",
"legacyCodeName": "NOT_SUPPORTED_ERR",
"legacyCodeValue": 9
},
"InUseAttributeError": {
"description": "The attribute is in use.",
"legacyCodeName": "INUSE_ATTRIBUTE_ERR",
"legacyCodeValue": 10
},
"InvalidStateError": {
"description": "The object is in an invalid state.",
"legacyCodeName": "INVALID_STATE_ERR",
"legacyCodeValue": 11
},
"SyntaxError": {
"description": "The string did not match the expected pattern.",
"legacyCodeName": "SYNTAX_ERR",
"legacyCodeValue": 12
},
"InvalidModificationError": {
"description": "The object can not be modified in this way.",
"legacyCodeName": "INVALID_MODIFICATION_ERR",
"legacyCodeValue": 13
},
"NamespaceError": {
"description": "The operation is not allowed by Namespaces in XML.",
"legacyCodeName": "NAMESPACE_ERR",
"legacyCodeValue": 14
},
"InvalidAccessError": {
"description": "The object does not support the operation or argument.",
"legacyCodeName": "INVALID_ACCESS_ERR",
"legacyCodeValue": 15
},
"SecurityError": {
"description": "The operation is insecure.",
"legacyCodeName": "SECURITY_ERR",
"legacyCodeValue": 18
},
"NetworkError": {
"description": "A network error occurred.",
"legacyCodeName": "NETWORK_ERR",
"legacyCodeValue": 19
},
"AbortError": {
"description": "The operation was aborted.",
"legacyCodeName": "ABORT_ERR",
"legacyCodeValue": 20
},
"URLMismatchError": {
"description": "The given URL does not match another URL.",
"legacyCodeName": "URL_MISMATCH_ERR",
"legacyCodeValue": 21
},
"QuotaExceededError": {
"description": "The quota has been exceeded.",
"legacyCodeName": "QUOTA_EXCEEDED_ERR",
"legacyCodeValue": 22
},
"TimeoutError": {
"description": "The operation timed out.",
"legacyCodeName": "TIMEOUT_ERR",
"legacyCodeValue": 23
},
"InvalidNodeTypeError": {
"description": "The supplied node is incorrect or has an incorrect ancestor for this operation.",
"legacyCodeName": "INVALID_NODE_TYPE_ERR",
"legacyCodeValue": 24
},
"DataCloneError": {
"description": "The object can not be cloned.",
"legacyCodeName": "DATA_CLONE_ERR",
"legacyCodeValue": 25
},
"EncodingError": {
"description": "The encoding operation (either encoded or decoding) failed."
},
"NotReadableError": {
"description": "The I/O read operation failed."
},
"UnknownError": {
"description": "The operation failed for an unknown transient reason (e.g. out of memory)."
},
"ConstraintError": {
"description": "A mutation operation in a transaction failed because a constraint was not satisfied."
},
"DataError": {
"description": "Provided data is inadequate."
},
"TransactionInactiveError": {
"description": "A request was placed against a transaction which is currently not active, or which is finished."
},
"ReadOnlyError": {
"description": "The mutating operation was attempted in a \"readonly\" transaction."
},
"VersionError": {
"description": "An attempt was made to open a database using a lower version than the existing version."
},
"OperationError": {
"description": "The operation failed for an operation-specific reason."
}
}