Standard built-ins

Error.cause

Try the free JavaScript compiler

Optional own cause property installed when supplied in options. It may be any value; it preserves context without requiring a particular Error type.

Formal Syntax & Structure

javascript syntaxjavascript
new Error(message, {cause: original})

Return Value

Any

Supplied cause, if present.

Working Example

Example Snippetjavascript
const root=new Error("root"); console.log(new Error("wrap",{cause:root}).cause===root);
JavaScript Reference