Throw Error instances rather than plain strings to capture stack traces. Modern JavaScript supports the `cause` property to chain root-cause errors.
js
throw new Error("Transaction broadcast failed", { cause: networkError });100 XP to Apprentice
throw, Error instances, and error chaining.
AI translates the explanation and quiz text while preserving code and answer scoring.
Throw Error instances rather than plain strings to capture stack traces. Modern JavaScript supports the `cause` property to chain root-cause errors.
js
throw new Error("Transaction broadcast failed", { cause: networkError });1. Why throw Error objects instead of strings?
2. What does { cause: err } provide?
3. What is the risk of an empty catch block?