DOMException

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

* Some parts of this feature may have varying levels of support.

Note: This feature is available in Web Workers.

The DOMException interface represents an abnormal event (called an exception) that occurs as a result of calling a method or accessing a property of a web API. This is how error conditions are described in web APIs.

Each exception has a name, which is a short "PascalCase"-style string identifying the error or abnormal condition.

DOMException is a Serializable object, so it can be cloned with structuredClone() or copied between Workers using postMessage().

Constructor

DOMException()

Returns a DOMException object with a specified message and name.

Instance properties

DOMException.code Read only

Returns one of the legacy error code constants, or 0 if none match.

DOMException.message Read only

Returns a string representing a message or description associated with the given error name.

DOMException.name Read only

Returns a string that contains one of the strings associated with an error name.

Error names

Common error names are listed here. Some APIs define their own sets of names, so this is not necessarily a complete list.

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. For example, this can be thrown by the Range object. (Legacy code value: 1 and legacy constant name: INDEX_SIZE_ERR)

HierarchyRequestError

The node tree hierarchy is not correct. (Legacy code value: 3 and legacy constant name: HIERARCHY_REQUEST_ERR)

WrongDocumentError

The object is in the wrong Document. (Legacy code value: 4 and legacy constant name: WRONG_DOCUMENT_ERR)

InvalidCharacterError

The string contains invalid characters. (Legacy code value: 5 and legacy constant name: INVALID_CHARACTER_ERR)

NoModificationAllowedError

The object cannot be modified. (Legacy code value: 7 and legacy constant name: NO_MODIFICATION_ALLOWED_ERR)

NotFoundError

The object cannot be found here. (Legacy code value: 8 and legacy constant name: NOT_FOUND_ERR)

NotSupportedError

The operation is not supported. (Legacy code value: 9 and legacy constant name: NOT_SUPPORTED_ERR)

InUseAttributeError

The attribute is in use. (Legacy code value: 10 and legacy constant name: INUSE_ATTRIBUTE_ERR)

InvalidStateError

The object is in an invalid state. (Legacy code value: 11 and legacy constant name: INVALID_STATE_ERR)

SyntaxError

The string did not match the expected pattern. (Legacy code value: 12 and legacy constant name: SYNTAX_ERR)

InvalidModificationError

The object cannot be modified in this way. (Legacy code value: 13 and legacy constant name: INVALID_MODIFICATION_ERR)

NamespaceError

The operation is not allowed by Namespaces in XML. (Legacy code value: 14 and legacy constant name: NAMESPACE_ERR)

InvalidAccessError

The object does not support the operation or argument. (Legacy code value: 15 and legacy constant name: INVALID_ACCESS_ERR)

TypeMismatchError

The type of the object does not match the expected type. (Legacy code value: 17 and legacy constant name: TYPE_MISMATCH_ERR) This value is deprecated; the JavaScript TypeError exception is now raised instead of a DOMException with this value.

SecurityError

The operation is insecure. (Legacy code value: 18 and legacy constant name: SECURITY_ERR)

NetworkError

A network error occurred. (Legacy code value: 19 and legacy constant name: NETWORK_ERR)

AbortError

The operation was aborted. (Legacy code value: 20 and legacy constant name: ABORT_ERR)

URLMismatchError

The given URL does not match another URL. (Legacy code value: 21 and legacy constant name: URL_MISMATCH_ERR)

QuotaExceededError

The quota has been exceeded. (Legacy code value: 22 and legacy constant name: QUOTA_EXCEEDED_ERR) It is a proper interface that derives from DOMException.

TimeoutError

The operation timed out. (Legacy code value: 23 and legacy constant name: TIMEOUT_ERR)

InvalidNodeTypeError

The node is incorrect or has an incorrect ancestor for this operation. (Legacy code value: 24 and legacy constant name: INVALID_NODE_TYPE_ERR)

DataCloneError

The object can not be cloned. (Legacy code value: 25 and legacy constant name: DATA_CLONE_ERR)

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).

Specifications

Specification
Web IDL
# idl-DOMException

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Bun
Deno
Node.js
DOMException
Chrome – Full support
Chrome 1 (Release date: 2008-12-11)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 1 (Release date: 2004-11-09)
footnote Full support
Opera – Full support
Opera 12.1 (Release date: 2012-11-20)
footnote Full support
Safari – Full support
Safari 1 (Release date: 2003-06-23)
footnote Full support
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 4 (Release date: 2011-03-29)
footnote Full support
Opera Android – Full support
Opera Android 12.1 (Release date: 2012-10-09)
footnote Full support
Safari on iOS – Full support
Safari on iOS 1 (Release date: 2007-06-29)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 1 (Release date: 2007-06-29)
footnote Full support
Bun – Full support
Bun 1 (Release date: 2023-09-08)
footnote Full support
Deno – Full support
Deno 1 (Release date: 2020-05-13)
footnote Full support
Node.js – Full support
Node.js 17 (Release date: 2021-10-19)
footnote Full support
DOMException() constructor
Chrome – Full support
Chrome 46 (Release date: 2015-10-13)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 37 (Release date: 2015-03-31)
footnote Full support
Opera – Full support
Opera 33 (Release date: 2015-10-27)
footnote Full support
Safari – Full support
Safari 10.1 (Release date: 2017-03-27)
footnote Full support
Chrome Android – Full support
Chrome Android 46 (Release date: 2015-10-14)
footnote Full support
Firefox for Android – Full support
Firefox for Android 37 (Release date: 2015-03-31)
footnote Full support
Opera Android – Full support
Opera Android 33 (Release date: 2015-11-03)
footnote Full support
Safari on iOS – Full support
Safari on iOS 10.3 (Release date: 2017-03-27)
footnote Full support
Samsung Internet – Full support
Samsung Internet 5 (Release date: 2016-12-15)
footnote Full support
WebView Android – Full support
WebView Android 46 (Release date: 2015-10-14)
footnote Full support
WebView on iOS – Full support
WebView on iOS 10.3 (Release date: 2017-03-27)
footnote Full support
Bun – Full support
Bun 1 (Release date: 2023-09-08)
footnote Full support
Deno – Full support
Deno 1 (Release date: 2020-05-13)
footnote Full support
Node.js – Full support
Node.js 17 (Release date: 2021-10-19)
footnote Full support
code
Deprecated
Chrome – Full support
Chrome 1 (Release date: 2008-12-11)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 1 (Release date: 2004-11-09)
footnote Full support
Opera – Full support
Opera 12.1 (Release date: 2012-11-20)
footnote Full support
Safari – Full support
Safari 1 (Release date: 2003-06-23)
footnote Full support
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 4 (Release date: 2011-03-29)
footnote Full support
Opera Android – Full support
Opera Android 12.1 (Release date: 2012-10-09)
footnote Full support
Safari on iOS – Full support
Safari on iOS 1 (Release date: 2007-06-29)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 1 (Release date: 2007-06-29)
footnote Full support
Bun – Full support
Bun 1 (Release date: 2023-09-08)
footnote Full support
Deno – Full support
Deno 1.7 (Release date: 2021-01-19)
footnote Full support
Node.js – Full support
Node.js 17 (Release date: 2021-10-19)
footnote Full support
message
Chrome – Full support
Chrome 1 (Release date: 2008-12-11)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 1 (Release date: 2004-11-09)
footnote Full support
Opera – Full support
Opera 12.1 (Release date: 2012-11-20)
footnote Full support
Safari – Full support
Safari 1 (Release date: 2003-06-23)
footnote Full support
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 4 (Release date: 2011-03-29)
footnote Full support
Opera Android – Full support
Opera Android 12.1 (Release date: 2012-10-09)
footnote Full support
Safari on iOS – Full support
Safari on iOS 1 (Release date: 2007-06-29)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 1 (Release date: 2007-06-29)
footnote Full support
Bun – Full support
Bun 1 (Release date: 2023-09-08)
footnote Full support
Deno – Full support
Deno 1 (Release date: 2020-05-13)
footnote Full support
Node.js – Full support
Node.js 17 (Release date: 2021-10-19)
footnote Full support
name
Chrome – Full support
Chrome 1 (Release date: 2008-12-11)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 1 (Release date: 2004-11-09)
footnote Full support
Opera – Full support
Opera 12.1 (Release date: 2012-11-20)
footnote Full support
Safari – Full support
Safari 1 (Release date: 2003-06-23)
footnote Full support
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 4 (Release date: 2011-03-29)
footnote Full support
Opera Android – Full support
Opera Android 12.1 (Release date: 2012-10-09)
footnote Full support
Safari on iOS – Full support
Safari on iOS 1 (Release date: 2007-06-29)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 1 (Release date: 2007-06-29)
footnote Full support
Bun – Full support
Bun 1 (Release date: 2023-09-08)
footnote Full support
Deno – Full support
Deno 1 (Release date: 2020-05-13)
footnote Full support
Node.js – Full support
Node.js 17 (Release date: 2021-10-19)
footnote Full support
DOMException is serializable
Chrome – Full support
Chrome 77 (Release date: 2019-09-10)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 101 (Release date: 2022-05-31)
footnote Full support
Opera – Full support
Opera 64 (Release date: 2019-10-07)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 77 (Release date: 2019-09-10)
footnote Full support
Firefox for Android – Full support
Firefox for Android 101 (Release date: 2022-05-31)
footnote Full support
Opera Android – Full support
Opera Android 55 (Release date: 2019-12-03)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 12 (Release date: 2020-06-19)
footnote Full support
WebView Android – Full support
WebView Android 77 (Release date: 2019-09-10)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support
Bun – Full support
Bun 1 (Release date: 2023-09-08)
footnote Full support
Deno – No support
Deno
footnote No support
Node.js – No support
Node.js
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Deprecated. Not for use in new websites.

See also