Skip to content

DOMException error code constants ​

The error code constants are 25 read-only numbers on DOMException, each a legacy numeric code, for comparing with code.

Value ​

A number.

  • On both the class and instances: DOMException.ABORT_ERR and err.ABORT_ERR are both 20.
  • Read-only. Assigning to them throws TypeError, and the values don't change.
ConstantValueCorresponding name
INDEX_SIZE_ERR1'IndexSizeError'
DOMSTRING_SIZE_ERR2None
HIERARCHY_REQUEST_ERR3'HierarchyRequestError'
WRONG_DOCUMENT_ERR4'WrongDocumentError'
INVALID_CHARACTER_ERR5'InvalidCharacterError'
NO_DATA_ALLOWED_ERR6None
NO_MODIFICATION_ALLOWED_ERR7'NoModificationAllowedError'
NOT_FOUND_ERR8'NotFoundError'
NOT_SUPPORTED_ERR9'NotSupportedError'
INUSE_ATTRIBUTE_ERR10'InUseAttributeError'
INVALID_STATE_ERR11'InvalidStateError'
SYNTAX_ERR12'SyntaxError'
INVALID_MODIFICATION_ERR13'InvalidModificationError'
NAMESPACE_ERR14'NamespaceError'
INVALID_ACCESS_ERR15'InvalidAccessError'
VALIDATION_ERR16None
TYPE_MISMATCH_ERR17'TypeMismatchError'
SECURITY_ERR18'SecurityError'
NETWORK_ERR19'NetworkError'
ABORT_ERR20'AbortError'
URL_MISMATCH_ERR21'URLMismatchError'
QUOTA_EXCEEDED_ERR22'QuotaExceededError'
TIMEOUT_ERR23'TimeoutError'
INVALID_NODE_TYPE_ERR24'InvalidNodeTypeError'
DATA_CLONE_ERR25'DataCloneError'

The three constants with values 2, 6, and 16 have no corresponding name; no DOMException has one of these as its code.

Examples ​

js
try {
  structuredClone(() => 1);
} catch (err) {
  if (err instanceof DOMException) {
    console.log(err.code === DOMException.DATA_CLONE_ERR, err.code === err.DATA_CLONE_ERR);
  }
}

Result: Prints true true.

See also ​