An error climbs Gang Kenari as an envelope from house to house: a catch with { cause } puts the old one inside a new envelope. What if one catch forgets…
In a real app, a network error passes through many layers (fetch, service, handler, UI). If every layer throws a new message without cause, the production log only says "Formulir gagal dikirim", and the real HTTP 500 is gone. { cause } (ES2022) lets one catch at the top trace all the way down.
{ cause } keeps the old error inside the new one
new Error(msg) without cause The original error’s context is thrown away. Always pass the source on: throw new Error(msg, { cause: err }).cause to show in the log by itself Many loggers print only message (and stack). Walk it yourself (e = e.cause) or use a logger that understands chains.{ cause: err }.{ cause: err } in both catches The whole chain: three messages, from the one the user sees down to HTTP 500.new Error(…) without cause The HTTP 500 envelope is crumpled at Rizal’s door: the root never reaches the neighbourhood head.return null The neighbourhood head prints "Terkirim!" though it failed: the most dangerous bug, a silent failure.e.message only The chain is whole, but only the outer envelope is opened. .cause does not print itself.