Documentación offline JavaScript main

SuppressedError() constructor

main Documentación oficial Licencia CC-BY-SA-2.5Descargado el 2026-08-02

En esta página

The SuppressedError() constructor creates {{jsxref("SuppressedError")}} objects.

Syntax#

new SuppressedError(error, suppressed)
new SuppressedError(error, suppressed, message)

SuppressedError(error, suppressed)
SuppressedError(error, suppressed, message)

[!NOTE] SuppressedError() can be called with or without new. Both create a new SuppressedError instance.

Parameters#

  • error
  • : The new error that results in the suppression of suppressed.
  • suppressed
  • : The error that was originally thrown and is now suppressed.
  • message {{optional_inline}}
  • : An optional human-readable description of the aggregate error.

[!NOTE] SuppressedError() does not accept options like {{jsxref("Error/Error", "Error()")}} and other subclasses do, because the semantics of {{jsxref("Error/cause", "cause")}} overlaps with suppressed.

Examples#

Creating a SuppressedError#

try {
  throw new SuppressedError(
    new Error("New error"),
    new Error("Original error"),
    "Hello",
  );
} catch (e) {
  console.log(e.suppressed); // Error: "Original error"
  console.log(e.error); // Error: "New error"
}

Specifications#

{{Specifications}}

Browser compatibility#

{{Compat}}

See also#