When wrapping or rethrowing an error, attach the original via Error.cause and include relevant context. Discarding the cause destroys the stack trace you need to debug.
Why This Matters
Re-throwing a new error without the cause loses the original stack trace, turning a quick fix into a multi-hour investigation.
Related Rules
Catch this automatically on every PR
BeforeMerge scans your pull requests against this rule and dozens more. Get actionable feedback before code ships.