Home

DOMException

DOMException is a built-in error type defined by the Document Object Model specifications to represent errors that occur when interacting with the DOM and related web platform APIs. It is used by various APIs and methods to indicate that an operation could not be completed due to invalid state, insufficient permissions, or other constraints. In JavaScript, DOMException is an object that inherits from Error and is typically accessible as window.DOMException in browsers.

The constructor and properties of DOMException follow a simple pattern. The constructor is new DOMException(message, name),

DOMException is used across many DOM and Web APIs to signal that an operation cannot proceed. The

Compatibility and notes: DOMException has wide support in modern browsers. The numeric code property is largely

where
the
first
argument
is
an
optional
human-friendly
description
and
the
second
argument
is
the
specific
error
name,
such
as
NotFoundError,
NotAllowedError,
NotSupportedError,
SecurityError,
NetworkError,
AbortError,
or
ConstraintError.
The
resulting
object
has
a
name
property
containing
the
error
name
and
a
message
property
with
the
description;
a
numeric
code
property
exists
in
some
environments
but
is
deprecated
in
modern
practice.
name
property
identifies
the
exact
error,
while
the
message
provides
additional
context.
Developers
often
handle
these
errors
with
try...catch
blocks
or
by
inspecting
error.name
in
promise
rejections
or
event
handlers.
obsolete,
and
code
checks
are
generally
discouraged
in
favor
of
examining
the
name.
While
developers
may
rarely
construct
DOMException
manually,
understanding
its
presence
helps
in
debugging
APIs
and
in
implementing
polyfills
or
error-mapping
layers
that
emulate
DOM
behavior.