Open this example in the interactive library
Source code
const error = new Error("Could not load settings", {
cause: new SyntaxError("Invalid JSON"),
});
console.log(error.cause.name);
Sample output
SyntaxError

Open this example in the interactive library
const error = new Error("Could not load settings", {
cause: new SyntaxError("Invalid JSON"),
});
console.log(error.cause.name);
SyntaxError