sindresorhus/serialize-error

Optionally preserve current stack

已關閉

#98 建立於 2024年9月25日

 (6 則留言) (0 個反應) (0 位負責人)JavaScript (69 個分叉)user submission
enhancementhelp wanted

倉庫指標

星標
 (599 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

An issue I found when throwing deserialized errors is that the thrown error has no reference to this throw point.

I think the "correct" way to throw serialized errors would be something like:

throw new Error(serialized.message, {
	cause: deserializeError(serialized),
});

Two drawbacks:

So how about:

throw deserializeError(serialized, {preserveStack: true});

貢獻者指南