DOMException()
The DOMException() constructor returns a DOMException object with a specified message and name.
Syntax
new DOMException()
new DOMException(message)
new DOMException(message, name)
Parameters
messageoptional- : A description of the exception. If not present, the empty string
''is used.
- : A description of the exception. If not present, the empty string
nameoptional- : A string. If the specified name is a standard error name, then getting the
codeproperty of theDOMExceptionobject will return the code number corresponding to the specified name.
- : A string. If the specified name is a standard error name, then getting the
Return value
A newly created DOMException object.
Error names
Common error names are listed here. Some APIs define their own sets of names, so this is not necessarily a complete list.
Note that the following deprecated historical errors don't have an error name but instead have only a legacy constant code value and a legacy constant name:
- Legacy code value:
2, legacy constant name:DOMSTRING_SIZE_ERR - Legacy code value:
6, legacy constant name:NO_DATA_ALLOWED_ERR - Legacy code value:
16, legacy constant name:VALIDATION_ERR
Note: Because historically the errors were identified by a numeric value that corresponded with a named variable defined to have that value, some of the entries below indicate the legacy code value and constant name that were used in the past.
IndexSizeError- : The index is not in the allowed range. (Legacy code value:
1and legacy constant name:INDEX_SIZE_ERR)
- : The index is not in the allowed range. (Legacy code value:
HierarchyRequestError- : The node tree hierarchy is not correct. (Legacy code value:
3and legacy constant name:HIERARCHY_REQUEST_ERR)
- : The node tree hierarchy is not correct. (Legacy code value:
WrongDocumentError- : The object is in the wrong
Document. (Legacy code value:4and legacy constant name:WRONG_DOCUMENT_ERR)
- : The object is in the wrong
InvalidCharacterError- : The string contains invalid characters. (Legacy code value:
5and legacy constant name:INVALID_CHARACTER_ERR)
- : The string contains invalid characters. (Legacy code value:
NoModificationAllowedError- : The object cannot be modified. (Legacy code value:
7and legacy constant name:NO_MODIFICATION_ALLOWED_ERR)
- : The object cannot be modified. (Legacy code value:
NotFoundError- : The object cannot be found here. (Legacy code value:
8and legacy constant name:NOT_FOUND_ERR)
- : The object cannot be found here. (Legacy code value:
NotSupportedError- : The operation is not supported. (Legacy code value:
9and legacy constant name:NOT_SUPPORTED_ERR)
- : The operation is not supported. (Legacy code value:
InvalidStateError- : The object is in an invalid state. (Legacy code value:
11and legacy constant name:INVALID_STATE_ERR)
- : The object is in an invalid state. (Legacy code value:
InUseAttributeError- : The attribute is in use. (Legacy code value:
10and legacy constant name:INUSE_ATTRIBUTE_ERR)
- : The attribute is in use. (Legacy code value:
SyntaxError- : The string did not match the expected pattern. (Legacy code value:
12and legacy constant name:SYNTAX_ERR)
- : The string did not match the expected pattern. (Legacy code value:
InvalidModificationError- : The object cannot be modified in this way. (Legacy code value:
13and legacy constant name:INVALID_MODIFICATION_ERR)
- : The object cannot be modified in this way. (Legacy code value:
NamespaceError- : The operation is not allowed by Namespaces in XML. (Legacy code value:
14and legacy constant name:NAMESPACE_ERR)
- : The operation is not allowed by Namespaces in XML. (Legacy code value:
InvalidAccessError- : The object does not support the operation or argument. (Legacy code value:
15and legacy constant name:INVALID_ACCESS_ERR)
- : The object does not support the operation or argument. (Legacy code value:
TypeMismatchErrordeprecated- : The type of the object does not match the expected type. (Legacy code value:
17and legacy constant name:TYPE_MISMATCH_ERR) This value is deprecated; the JavaScriptTypeErrorexception is now raised instead of aDOMExceptionwith this value.
- : The type of the object does not match the expected type. (Legacy code value:
SecurityError- : The operation is insecure. (Legacy code value:
18and legacy constant name:SECURITY_ERR)
- : The operation is insecure. (Legacy code value:
NetworkError- : A network error occurred. (Legacy code value:
19and legacy constant name:NETWORK_ERR)
- : A network error occurred. (Legacy code value:
AbortError- : The operation was aborted. (Legacy code value:
20and legacy constant name:ABORT_ERR)
- : The operation was aborted. (Legacy code value:
URLMismatchError- : The given URL does not match another URL. (Legacy code value:
21and legacy constant name:URL_MISMATCH_ERR)
- : The given URL does not match another URL. (Legacy code value:
QuotaExceededError- : The quota has been exceeded. (Legacy code value:
22and legacy constant name:QUOTA_EXCEEDED_ERR)
- : The quota has been exceeded. (Legacy code value:
TimeoutError- : The operation timed out. (Legacy code value:
23and legacy constant name:TIMEOUT_ERR)
- : The operation timed out. (Legacy code value:
InvalidNodeTypeError- : The node is incorrect or has an incorrect ancestor for this operation. (Legacy code value:
24and legacy constant name:INVALID_NODE_TYPE_ERR)
- : The node is incorrect or has an incorrect ancestor for this operation. (Legacy code value:
DataCloneError- : The object can not be cloned. (Legacy code value:
25and legacy constant name:DATA_CLONE_ERR)
- : The object can not be cloned. (Legacy code value:
EncodingError- : The encoding or decoding operation failed (No legacy code value and constant name).
NotReadableError- : The input/output read operation failed (No legacy code value and constant name).
UnknownError- : The operation failed for an unknown transient reason (e.g. out of memory) (No legacy code value and constant name).
ConstraintError- : A mutation operation in a transaction failed because a constraint was not satisfied (No legacy code value and constant name).
DataError- : Provided data is inadequate (No legacy code value and constant name).
TransactionInactiveError- : A request was placed against a transaction that is currently not active or is finished (No legacy code value and constant name).
ReadOnlyError- : The mutating operation was attempted in a "readonly" transaction (No legacy code value and constant name).
VersionError- : An attempt was made to open a database using a lower version than the existing version (No legacy code value and constant name).
OperationError- : The operation failed for an operation-specific reason (No legacy code value and constant name).
NotAllowedError- : The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission (No legacy code value and constant name).