What does error.cause give you when you wrap one error in another?
function loadConfig(text) {
try {
return JSON.parse(text);
} catch (error) {
throw new Error("Config is not valid JSON", { cause: error });
}
}
try {
loadConfig("{ broken");
} catch (error) {
console.log(error.message);
console.log(error.cause.name);
console.log(error.cause instanceof SyntaxError);
}
console.log("cause" in new Error("plain"));
The answer
Work out every line it logs, in order. Then check.
Checking your sign-in…